Is this the one they call Kadane's algorithm or something
@messiisthebest24 күн бұрын
Yes
@soumyadeepdas77024 күн бұрын
This video has subtitles available.
@jeromelawrence981923 күн бұрын
Using sliding windows algorithm is much easier
@TF2Shows20 күн бұрын
it wont work with negative numbers
@waidenf14 күн бұрын
thats for fixed lengths genius.
@ahmadramadhan904323 күн бұрын
u can using prefix sum and make variable to save the minimum prefix sum and then every index you check if the current prefix minus minimum prefix before
@prabhatjha65324 күн бұрын
Nice, thought of the same solution, but didn’t know this is the famous Kadane’s algorithm, I always hear this name but didn’t knew. Thanks
@rohitgarg39424 күн бұрын
Two pointers/sliding window
@jackybanh810524 күн бұрын
the issue with your solution, you memorised a specific algorithm to solve the question optimally. this is not the point of the coding interview, its literally a proxy on how you approach the answer not memorising a technique
@user-qs1lh1qv1d20 күн бұрын
what colour is your lamborgini?
@sathwikreddy17524 күн бұрын
By currentmax will point at arr[0] and add arr[1] and check cuurentmax is less than or greater than arr[i] and update it to max sofar the highest values ant iterate
@Manoharofficial18021 күн бұрын
Why your solving the question in python
@boomer69824 күн бұрын
is he speaking english cuz i dont understand a word😢
@jonathanjohnson278522 күн бұрын
He has an accent but I understand him perfectly. Very helpful Sahil❤
@ahmadabid784523 күн бұрын
What if we devise the array into two other arrays negative and positive and we just add up the positive array but this doesn't match the example ig is that ok?
@LikemyCommentt13 күн бұрын
It should be continuous
@Vivek-ru9vd17 күн бұрын
we can do it by brute force
@ForgottenKnight123 күн бұрын
It's funny how the first example is wrong - the largest subarray would be [1,4,2,1,4] - why ? because nowhere in that requirement is there any specifications about not dismissing duplicates. Also, why would you choose e negative number that will decrease your sum? That's just dumb, imho. Even [4,2,1] would have been a better option. Who makes these problems ? :)))
@sahilandsarra23 күн бұрын
If only you could do one Google search
@shantanushekharsjunerft978324 күн бұрын
Isn’t 1,4,2,1,4 the subarray with largest sum?
@Shhhh-ni5jw24 күн бұрын
That’s a subsequence
@gunabaki775523 күн бұрын
A subarray should contain only contiguous elements, not just random nums from array
@entertainercartoons23 күн бұрын
@@Shhhh-ni5jw can you explain that
@ForgottenKnight123 күн бұрын
@@Shhhh-ni5jw An array is a collection, and can contain one or more elements, or none, in any order, with duplication or without. What are you talking about?
@SOSSVT24 күн бұрын
Do they impose a language or you could solve the problem with any coding language?
@snehalpatil752824 күн бұрын
Any language is fine
@user-fc6wv1wy7e24 күн бұрын
@@snehalpatil7528 wait so like they would give you this problem and you would try and solve it on any programming language or you have to use your brain to solve it
@rohhanbhardwaj18 күн бұрын
@@user-fc6wv1wy7ebro any language works
@aquibchishti850324 күн бұрын
this is brain f 😮🎉😢
@lisiasty68819 күн бұрын
Can't we just try add number and if number lowers sum then revert this? For every number in array And then not reverted numbers will be just numbers than are not in subarray I think it would be O(n)