tag:blogger.com,1999:blog-4731036105252322780.post213904357897584139..comments2024-03-01T02:55:58.951-08:00Comments on Buttercola: Leetcode: Maximum Size Subarray Sum Equals kButter is looking for a jobhttp://www.blogger.com/profile/01481083468821703855noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-4731036105252322780.post-67654713636619621512021-10-05T18:41:17.085-07:002021-10-05T18:41:17.085-07:00What a genius!!! Thank you for your clear explanat...What a genius!!! Thank you for your clear explanation! I am from the future 2021, and thank you a random stranger from 2016!!Anonymoushttps://www.blogger.com/profile/08569235040754885292noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-10817071131616528542019-08-15T21:29:00.976-07:002019-08-15T21:29:00.976-07:00Dictionary map = new Dictionary();
int... Dictionary map = new Dictionary();<br /> int sum = 0, maxLength = 0;<br /> for (int i = 0; i < nums.Length; i++)<br /> {<br /> sum += nums[i];<br /> if (sum == k)<br /> {<br /> maxLength = i + 1;<br /> }<br /> if (!map.ContainsKey(sum))<br /> {<br /> map.Add(sum, i);<br /> }<br /> if (map.ContainsKey(sum - k))<br /> {<br /> maxLength = Math.Max(maxLength, i - map[sum - k]);<br /> }<br /> }<br /><br /> return maxLength;Tushar Budhehttps://www.blogger.com/profile/04841274865710903287noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-43082979405850928572019-08-15T19:40:12.769-07:002019-08-15T19:40:12.769-07:00This comment has been removed by the author.Tushar Budhehttps://www.blogger.com/profile/04841274865710903287noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-14206144662014434822018-05-21T16:16:34.670-07:002018-05-21T16:16:34.670-07:00This comment has been removed by the author.Pranav Saxenahttps://www.blogger.com/profile/16978351502401993201noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-80536735555181415192017-06-06T10:17:54.796-07:002017-06-06T10:17:54.796-07:00indexes 3 to 5, using a zero-base (i3=0, i4=1, i5=...indexes 3 to 5, using a zero-base (i3=0, i4=1, i5=2 -> 0+1+2 -> 3)zeesidehttps://www.blogger.com/profile/15436759622337985438noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-40633030539102735452017-01-17T09:16:27.599-08:002017-01-17T09:16:27.599-08:00Hi,
if array = {1, 2, 1, 0, 1, 2, 1}
and k = 3
it ...Hi,<br />if array = {1, 2, 1, 0, 1, 2, 1}<br />and k = 3<br />it should return 5 (longest sub-array is from 1 included to 5 included)<br />but it returns 3Anonymoushttps://www.blogger.com/profile/07915792191904419591noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-11659415705902625252016-10-28T10:07:16.440-07:002016-10-28T10:07:16.440-07:00Genius.Genius.Dexterhttps://www.blogger.com/profile/10936256644371606713noreply@blogger.comtag:blogger.com,1999:blog-4731036105252322780.post-69525262335682950532016-04-16T16:23:35.837-07:002016-04-16T16:23:35.837-07:00Good Solution!Good Solution!Maitreyahttps://www.blogger.com/profile/02311759702333817115noreply@blogger.com