<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amina Mohamed</title>
    <description>The latest articles on DEV Community by Amina Mohamed (@ermeener).</description>
    <link>https://dev.to/ermeener</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2306271%2Fdfcea22f-bf1c-4d9b-be76-867cf4316157.png</url>
      <title>DEV Community: Amina Mohamed</title>
      <link>https://dev.to/ermeener</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ermeener"/>
    <language>en</language>
    <item>
      <title>Solution to Leetcode’s Maximum Subarray-JS(53)</title>
      <dc:creator>Amina Mohamed</dc:creator>
      <pubDate>Thu, 04 Sep 2025 11:15:48 +0000</pubDate>
      <link>https://dev.to/ermeener/solution-to-leetcodes-maximum-subarray-js53-l10</link>
      <guid>https://dev.to/ermeener/solution-to-leetcodes-maximum-subarray-js53-l10</guid>
      <description>&lt;p&gt;let maxSubArray=function(nums) {&lt;br&gt;
    let maxSum=nums[0]&lt;br&gt;
    let currentSum=nums[0]&lt;br&gt;
    for(let i=1;i&amp;lt;nums.length;i++){&lt;br&gt;
        currentSum=Math.max(currentSum+nums[i],nums[i])&lt;br&gt;
        maxSum=Math.max(currentSum,maxSum)&lt;br&gt;
    }&lt;br&gt;
    return maxSum&lt;/p&gt;

&lt;p&gt;};&lt;br&gt;
//CODE EXPLANATION -This is Kadane’s Algorithm&lt;br&gt;
Maximum sum of a contiguous subarray :this means a sequence of numbers that appear next to each other&lt;br&gt;
for Case 1=[-2,1,-3,4,-1,2,1,-5,4]&lt;br&gt;
so we have the currentSum it iterates through the array.&lt;br&gt;
Step1:&lt;br&gt;
Initialize currentSum=-2,maxSum=-2&lt;br&gt;
currentSum=Math.max(-2+1,1)=1&lt;br&gt;
maxSum=Math.max(1,-2)=1&lt;br&gt;
Step2:&lt;br&gt;
currentSum=1&lt;br&gt;
currentSum=Math.max(1+(-3),-3)=-2&lt;br&gt;
maxSum=Math.max(-2,1)=1&lt;br&gt;
Step3:&lt;br&gt;
currentSum=-2&lt;br&gt;
currentSum=Math.max(-2+4,4)=4&lt;br&gt;
maxSum=Math.max(4,1)=4&lt;br&gt;
Step4:&lt;br&gt;
currentSum=4&lt;br&gt;
currentSum=Math.max(4+(-1),-1)=3&lt;br&gt;
maxSum=Math.max(3,4)=4&lt;br&gt;
Step5:&lt;br&gt;
currentSum=3&lt;br&gt;
currentSum=Math.max(3+(2),2)=5&lt;br&gt;
maxSum=Math.max(5,4)=5&lt;br&gt;
Step6:&lt;br&gt;
currentSum=5&lt;br&gt;
currentSum=Math.max(5+(1),1)=6&lt;br&gt;
maxSum=Math.max(6,5)=6&lt;br&gt;
Step7:&lt;br&gt;
currentSum=6&lt;br&gt;
currentSum=Math.max(6+(-5),-5)=1&lt;br&gt;
maxSum=Math.max(1,6)=6&lt;br&gt;
Step8:&lt;br&gt;
currentSum=1&lt;br&gt;
currentSum=Math.max(1+(4),4)=5&lt;br&gt;
maxSum=Math.max(5,6)=6&lt;/p&gt;

&lt;p&gt;I hope you understand. If you found this helpful or have your own way of thinking about it, drop a comment below!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
