LeetCode Challenge Day 3 - Max Subarray

  Рет қаралды 73,546

Errichto Algorithms

Errichto Algorithms

4 жыл бұрын

Max Subarray and Kadane's algorithm. You should already know this if you prepare for coding interviews. Make sure to check out an alternative solution at 7:05 though!
Leetcode holds a 30-day Challenge in April with a new coding interview problem appearing each day. I'm participating and will upload a video for each day just after the deadline at midnight PST. Participate here leetcode.com/explore/featured...
Subscribe for more educational videos on algorithms, coding interviews and competitive programming.
- Github repository: github.com/Errichto/youtube
- Live streams on 2nd YT channel and on Twitch: / errichto2 & / errichto
- FB and Twitter: / errichto & / errichto
- Frequently Asked Questions: github.com/Errichto/youtube/w...
#Coding #Programming

Пікірлер: 223
@Errichto
@Errichto 4 жыл бұрын
Today is Google Code Jam qualification round! codingcompetitions.withgoogle.com/codejam Also, I should have just used a=max(x,a+x).
@iitnakanpur..
@iitnakanpur.. 4 жыл бұрын
@Errichto congrats you got 2nd in qualification round, And iam still try to find bug in my first problem😅😅😅
@rahulbhatia1313
@rahulbhatia1313 4 жыл бұрын
😂😂😂
@iitnakanpur..
@iitnakanpur.. 4 жыл бұрын
@@wanderer1603 this is not the way of doing any competition, so please try it your own, and if you still stuck then I can help you
@FoodieKing
@FoodieKing 4 жыл бұрын
@@iitnakanpur.. I am done with the the first problem of codejam
@iitnakanpur..
@iitnakanpur.. 4 жыл бұрын
@@FoodieKing bro it's awkward to say but IAM still stuck at first problem , my code is just failing in last test case don't know why, Can you help
@ritiktwopointo2691
@ritiktwopointo2691 4 жыл бұрын
Errichto, I dont know if anyone has noticed but you have got an unknown side of a good sense of humor. Also, thank you so very much for helping hundreds of thousands of guys out there. Keep up the good work
@cobrandrewg9995
@cobrandrewg9995 4 жыл бұрын
* gets 2 nd place in codejam qualifiers* "Ok that was boring, let's make a KZbin video now"
@gamarayburst1258
@gamarayburst1258 4 жыл бұрын
lol, it's just qualifiers. Wait till final where our gennedy boi will be first and this boi will be 2nd.
@iitnakanpur..
@iitnakanpur.. 4 жыл бұрын
@@gamarayburst1258 but I didn't see gennady in qualification round. Is it not participating
@Errichto
@Errichto 4 жыл бұрын
@@iitnakanpur.. It was 3am in Russia and Belarus when the competition started. It's healthier to sleep and then participate during a day ;)
@iitnakanpur..
@iitnakanpur.. 4 жыл бұрын
@@Errichto oh that's the reason, although gennady is not participating it is not possible since he is winning from last 6 years😂😂
@almuhimen8023
@almuhimen8023 4 жыл бұрын
@@iitnakanpur.. Gennedy is already in the final
@pratikchandraIC
@pratikchandraIC 4 жыл бұрын
who didn't know about Kadane's algorithm ? ✋ (me)
@chitranshsaxena59
@chitranshsaxena59 4 жыл бұрын
so, not a single person, lol
@Tanvir-xw8rc
@Tanvir-xw8rc 4 жыл бұрын
I didn't know also
@sauravpaul4131
@sauravpaul4131 4 жыл бұрын
So you are married or committed? 🤣 Cz every single person know it
@camenraidercc6625
@camenraidercc6625 4 жыл бұрын
Don't stop with this series I'm learning so much!!!
@subarukun8001
@subarukun8001 4 жыл бұрын
3:17 the question that comes on my mind while I solve new problems.
@TwitchCronos100
@TwitchCronos100 4 жыл бұрын
me on every problem
@jitendraraghuwanshi1365
@jitendraraghuwanshi1365 4 жыл бұрын
always
@AidenBai
@AidenBai 4 жыл бұрын
damn, that fingercrack really got me
@FromTheMountain
@FromTheMountain 4 жыл бұрын
I got this exact problem as a homework question recently, spent hours on it until I finally came up with this algorithm. Little did I know, it was one of the most well known programming interview questions...
@rickyleung9312
@rickyleung9312 4 жыл бұрын
Makes me smile when I see the missing “int a = 0” after the amazing quick modification to handle the negative numbers.
@Shounak2411
@Shounak2411 4 жыл бұрын
Dude, great videos. I like that you mess up sometimes. It helps me, as a viewer who doesn't participate in competitions, to keep in mind that it is not necessary to get the code correct in the first try . You try and figure out what is wrong and correct it. And when you get it right, it's great. So thanks and best of luck for your future.
@Errichto
@Errichto 4 жыл бұрын
Thanks :)
@rockyjoe3817
@rockyjoe3817 4 жыл бұрын
Amazing Errichto Just Amazing . One of the best things is to learn how smart people think when solving problems!!!!!!
@jimwoodward7293
@jimwoodward7293 4 жыл бұрын
"In this episode of Errichto complains ...." -- these videos are great!! This basically boils down to a typing exercise for you!
@lovvyparhar393
@lovvyparhar393 4 жыл бұрын
If you don't know the algorithm then read the book mentioned by Errichto in the beginner cp video, it is great! We can alternately keep the first element in the ans and then use loop from i = 1 to n and apply the kadane's algorithm, it will also work.
@rockyjoe3817
@rockyjoe3817 4 жыл бұрын
Ah do you know the name of the book?
@lovvyparhar393
@lovvyparhar393 4 жыл бұрын
@@rockyjoe3817 Competitive Programming Handbook by A Laaksonen
@rockyjoe3817
@rockyjoe3817 4 жыл бұрын
@@lovvyparhar393 THANKS :DDDDD
@aayushlamichhane
@aayushlamichhane 3 жыл бұрын
i laughed too hard when he said "am i stupid or something"
@flyingcanopy5611
@flyingcanopy5611 4 жыл бұрын
Your explanation is so effortless . Easy to understand ..
@codearabawy
@codearabawy 4 жыл бұрын
Thanks, Errichto! That was an informative video for me.
@walthertrgovac6087
@walthertrgovac6087 4 жыл бұрын
Please continue to explain how to do the tasks and what you did because that is why we are watching. If I knew what Kadane's algorithm is, I wouldn't be here lol
@junghoryu850
@junghoryu850 4 жыл бұрын
I solved three problems in google Code Jam so far and I saw you as top two! You are so good!
@FoodieKing
@FoodieKing 4 жыл бұрын
Please connect wid me...
@videocorner3305
@videocorner3305 4 жыл бұрын
Bro is Codejam submission is over It's showing me an option to submit the solution Im confused Can u please confirm this
@colios137
@colios137 4 жыл бұрын
@@videocorner3305 no codejam is not over u can submit your code!
@junghoryu850
@junghoryu850 4 жыл бұрын
@@FoodieKing Sorry I went to sleep afterwards... I'm from Toronto so the time zone difference
@starllama2149
@starllama2149 4 жыл бұрын
@@junghoryu850 don't give away your location so freely man
@imml97
@imml97 4 жыл бұрын
Well you are a genius, and I can certainly say so as I've never seen someone code it twice and under 20s and then saying "Well the problem statement is". 🙌
@sarahb5340
@sarahb5340 3 жыл бұрын
This is like the speedcubers who plan the entire solution before making their first move.
@olayinkaanifowose5099
@olayinkaanifowose5099 3 ай бұрын
first time seeing this, proud of myself that i was able to come up with the alternative prefix sum algorithm within minutes. Never heard of kadane's algorithm before.
@shubhamk840
@shubhamk840 4 жыл бұрын
It's great to see errichto getting more confident video by video.
@siddvideos
@siddvideos 4 жыл бұрын
Thanks @Errichto, excellent explanation.
@vaibhavsingh3550
@vaibhavsingh3550 4 жыл бұрын
Please explain codejam qualifying problems also especially the last two once. It would be really helpful.
@stonecoldcold2941
@stonecoldcold2941 4 жыл бұрын
Awesome Man , keep up the good work!
@Aditya-us5gj
@Aditya-us5gj 4 жыл бұрын
Hey Errichto, In the last line question it was written that if you know O(n) solution then try to target divide and conquer strategy. Whereas if I'm not wrong, kadane's algorithm falls in DP category. Can you suggest any divide and conquer strategy for the same question ?
@Errichto
@Errichto 4 жыл бұрын
Divide&Conquer boils down to finding the best interval that passes through the middle of a sequence. Go from the middle to the left and find the biggest sum (of suffix of left half), same when going from the middle to the right (biggest sum of prefix of right half), and add those two numbers.
@erikawwad7653
@erikawwad7653 3 жыл бұрын
Thanks for educating me, the single person!!
@ascyrax8507
@ascyrax8507 4 жыл бұрын
u rock Kamil!!!!Big fan of yours.
@CREATORSPVTLTD
@CREATORSPVTLTD 4 жыл бұрын
can someone help me out in the Parenting Partnering Returns question, Explanations or Hints or Tricks would be great : (
@sum5619
@sum5619 4 жыл бұрын
Dang it errichto, I was hoping you could've explained the follow up question for divide and conquer. I did it before but coming back to it I lost all understanding of what I did...
@siddharth_singh9
@siddharth_singh9 4 жыл бұрын
@Errichto do you think solving the indicium program using magic square algorithm is correct ??
@arinroday302
@arinroday302 4 жыл бұрын
You really do have a good sense of humour
@shashankdubey983
@shashankdubey983 4 жыл бұрын
erichto Is there any way that while finding all the subsequences of an array,we can seprate all subarrays from subsequences at the same time??
@almuhimen8023
@almuhimen8023 4 жыл бұрын
Thats gonna take way lot time and gice you a TLE
@akashdubey8341
@akashdubey8341 4 жыл бұрын
Sir will you please make video tutorials of hackerearth circuit problems.
@anashashim
@anashashim 4 жыл бұрын
Could you make a video about HashCode and how can a team prepare for it?
@diveshchowdary2124
@diveshchowdary2124 4 жыл бұрын
will you make a video which will explain your template for cpp
@pulakmalhotra5816
@pulakmalhotra5816 4 жыл бұрын
What is the divide and conquer approach as mentioned in the problem statement?
@silverzero9524
@silverzero9524 4 жыл бұрын
i clicked this video for exactly that :(
@_Ani_
@_Ani_ 4 жыл бұрын
"Measure myself" - instantly corrects xD
@_Ani_
@_Ani_ 4 жыл бұрын
Day 4 solution : class Solution { public: void moveZeroes(vector& nums) { int c=0; for (int i = 0; i < nums.size() ; i++) if (nums[i] != 0) swap(nums[c++], nums[i]); } };
@ramaranneh
@ramaranneh 4 жыл бұрын
Hi... can anyone explain me the different between the first line he wrote a =max(0,a+x) and the two lines he wrote instead a+=x; a=max(a,0); thanks in advance
@abhishek_k_jha
@abhishek_k_jha 4 жыл бұрын
Will you post explained solution of code jam tomorrow??
@DiAd188
@DiAd188 4 жыл бұрын
why do I have adrenaline rush before you start hahahhahahah :'D
@i_vikassharma
@i_vikassharma 4 жыл бұрын
could you please tell which timer program are you using to track the time in this video?
@tanishqupadhayay1350
@tanishqupadhayay1350 4 жыл бұрын
I am that single person who hasn't heard about this algo / So thanks Errichto! keep this up
@munkh-odganzorigt7497
@munkh-odganzorigt7497 4 жыл бұрын
him: hello my fellow programmers me: hello god
@davidjojic6772
@davidjojic6772 4 жыл бұрын
I started reading Competitive Programmer's Handbook and and i got stuck when Backtracking came, after that came some a lot of difficult chapters that i did not understand. Do i continue reading the book if i dont understand. I started doing task from Codeforces. PS. I love your videos
@Errichto
@Errichto 4 жыл бұрын
Maybe practice some problems now and get better understanding of them. Once you are good at easy problems, move on to harder topics. Imagine just reading a big math book without solving many problems. You will be lost in the middle without a good grasp of what happened earlier.
@prakash_77
@prakash_77 4 жыл бұрын
I think Erricto said to maintain balance reading the book and practicing, not merely reading the book and/or implementing. Getting stuck is normal. Don't move forward. Maybe practice some problems on Backtracking itself.
@shashanktiwari4442
@shashanktiwari4442 4 жыл бұрын
Pls also post the video of codejam qualification after it ends thx
@christianantonyquero6642
@christianantonyquero6642 4 жыл бұрын
Is there any tutorial on how Errichto cracks his hands?
@rakesht.j664
@rakesht.j664 4 жыл бұрын
Hey man can u make a video how to think and solve these kinds of problems.......
@chauhan1999
@chauhan1999 4 жыл бұрын
What's the name of that Timer app? Is it Google timer if yes how did you pin it because I can open it only in one tab in windows.
@osamaataullah3723
@osamaataullah3723 4 жыл бұрын
I stuck in codejam 3rd problem can any1 help plz?
@shreyanshsingh2627
@shreyanshsingh2627 4 жыл бұрын
0:02 -- You haven't trained enough for CP today if you hands don't crack like that when you leave the keyboard
@jameshello38
@jameshello38 4 жыл бұрын
Errichto is getting better every video. May be he implemented neural network.
@brianhuang9257
@brianhuang9257 4 жыл бұрын
What is the divide and conquer solution?
@prasoonsingh533
@prasoonsingh533 4 жыл бұрын
Brian Huang in this we will use divide and conquer approach By dividing the array in two equal halves
@hacker-7214
@hacker-7214 4 жыл бұрын
you are a code jam champion. it took me whole day to solve 2 problems and i got stuck on problem 3. the overlapping interval. i gave up lol. im now 20k in the leaderboard :( XD
@satviknema8629
@satviknema8629 4 жыл бұрын
This guy stood second in Google code jam today. GG
@md.romizulislam7416
@md.romizulislam7416 3 жыл бұрын
wat a start :')
@UdayKiran-mw4cr
@UdayKiran-mw4cr 2 жыл бұрын
Which software are you using for the timer(The one which is under your picture in video) ? I would like to try my timings
@PravinMali
@PravinMali 4 жыл бұрын
What is the timer app or extension that you used in the video?
@Errichto
@Errichto 4 жыл бұрын
I googled stopwatch and it was there. Some google/chrome tool.
@tkctko
@tkctko 4 жыл бұрын
I didn't know there are a couple of solutions. I knew only divide and conquer approach.
@UnfunnyXavier
@UnfunnyXavier 4 жыл бұрын
I saw similar problem but a bit more to it, it was like you have to find maximum subarray but the array element are treated as circular i.e if array is [ 7,-1,2,-11,4,7,-1] then the maximum sum is 18 from i=4 to i=2 can you help in that case plz
@shashwatkhanna6036
@shashwatkhanna6036 4 жыл бұрын
Let's say we have an array [1,2,3] Make another array [1,2,3,1,2,3] and then solve it like you normally would. There's probably a better way, but this seems like the simplest. Or you could run a loop from 0 to 2n and access the array as a[i%n]
@UnfunnyXavier
@UnfunnyXavier 4 жыл бұрын
@@shashwatkhanna6036 but the answer of your example will be 12 while max sum from orignal array was 6
@samgal9205
@samgal9205 3 жыл бұрын
@@UnfunnyXavier In addition to finding internal max subarray like here, you can find two max sums while being pinned to left and right most elements. You can do that in two passes, one forward and one reverse. Then you take max of internal or left+right
@twrskshm
@twrskshm 4 жыл бұрын
If its an empty array, the for loop will not be entered and the function will return the value of INT_MIN
@BarkaDog
@BarkaDog 4 жыл бұрын
It cannot be an empty array it's clearly written in the question
@vikashkumandan
@vikashkumandan 4 жыл бұрын
I also followed the same logic as kadane’s algo without knowing it but my code was 25 lines long .. not 5 and i took time about 15-20 mins to complete my code and submit 😂 do you have any tips on how we can reduce lines of code or steps to follow to keep reducing our code to be much readable
@Errichto
@Errichto 4 жыл бұрын
idk, see for repeated parts and extract them?
@vikashkumandan
@vikashkumandan 4 жыл бұрын
Yaa i will check now and remove as much as possible by me 😊
@jenniefine9456
@jenniefine9456 4 жыл бұрын
You are the only one CP KZbinr which i like 🥰
@askaraskar1472
@askaraskar1472 4 жыл бұрын
Like smash before watching!
@syeda.k.2934
@syeda.k.2934 4 жыл бұрын
difficult to watch on small screen, pls increase resolution or zoom in.
@sahilsharma2952
@sahilsharma2952 4 жыл бұрын
Errichto Do you have a discord server?
@TheJack2HD
@TheJack2HD 4 жыл бұрын
Google jam video when contest is over plz :D
@sufyan2317
@sufyan2317 4 жыл бұрын
And yes congo !!!!!!!!!!!! 2nd place in code jam ... i managed to solve first 4 ...feeling exhausted😂😂
@prakash_77
@prakash_77 4 жыл бұрын
Were they easy?
@sufyan2317
@sufyan2317 4 жыл бұрын
@@prakash_77 first 3 were easy!!!!!!
@Anto-xh5vn
@Anto-xh5vn 3 жыл бұрын
I am that one person who doesn't know kadane's algorithm :D Thanks tor explaining
@limakbear7029
@limakbear7029 3 жыл бұрын
Kadane's Algorithm 😀
@Anto-xh5vn
@Anto-xh5vn 3 жыл бұрын
@@limakbear7029 ooh thanks for correcting me mate
@mr.mystiks9968
@mr.mystiks9968 4 жыл бұрын
I was hoping the alternative solution would be a divide and conquer recursive solution :(
@r0l3ex20
@r0l3ex20 4 жыл бұрын
When you are typing you hold your fingers in "Home Row Position"?
@akashdubey8341
@akashdubey8341 4 жыл бұрын
i think everybody does that!!!!!!!!
@Errichto
@Errichto 4 жыл бұрын
I don't know what that is. Do I keep fingers on second row of keyboard (ASDFJKL:)? Yes
@shresthmishra9329
@shresthmishra9329 4 жыл бұрын
hahahahahahhahahaa nice start.i wonder how many retakes you took for that
@saurabhmittal2145
@saurabhmittal2145 4 жыл бұрын
Hi Errichto in this problem there is follow up that we can do it in O(log(n)) but you have done it in O(n) which tell us more efficient solution.
@Errichto
@Errichto 4 жыл бұрын
The follow-up is slower O(n*log(n)) approach. You can't do anything faster than O(n) because you need to go through the whole array at least once to know the sum of possibly all elements.
@saurabhmittal2145
@saurabhmittal2145 4 жыл бұрын
@@Errichtook Thank you so much sir.
@danylopolishchuk1748
@danylopolishchuk1748 4 жыл бұрын
That finger cracking .That shit scares me
@kevintlu
@kevintlu 4 жыл бұрын
"Am I stupid or something", oh boy
@danielsegura1568
@danielsegura1568 2 жыл бұрын
where are you from? you sound like my ex from serbia , easter european? just curious
@rakeshhotker4762
@rakeshhotker4762 4 жыл бұрын
Thanks
@mahdi7d1rostami
@mahdi7d1rostami 4 жыл бұрын
The sound in the beginning...! Was it real?
@Errichto
@Errichto 4 жыл бұрын
Yes, it was :>
@travissun6753
@travissun6753 4 жыл бұрын
kzbin.info/www/bejne/q57XaKdnlL1riMU When you explain the algorithm, what drawing board software are you using?
@Yogesh-bp4vv
@Yogesh-bp4vv 4 жыл бұрын
😍When you are beginner, how much time you take to solve problem because now i take 20-30min or sometimes 1hr to solve a problem please aanswer.
@Errichto
@Errichto 4 жыл бұрын
Depends on how difficult problems you're solving... can be 3 minutes, can be 3 hours.
@Yogesh-bp4vv
@Yogesh-bp4vv 4 жыл бұрын
@@Errichtoso it means you also take 3hour to solve a problem sometimes. I thought I was the only one. Who takes sometime 2-3 hours to solve a problem. Thank you😍
@electromorphous9567
@electromorphous9567 4 жыл бұрын
They still have a month. They're starting off with easy problems which will get hard towards the end.
@Errichto
@Errichto 4 жыл бұрын
I'm not complaining about the difficulty. The style of problems is bad, they are bad for beginners.
@almuhimen8023
@almuhimen8023 4 жыл бұрын
I solved it faster than you. How? I solved it yesterday!🤣
@abdelrahmanadel8998
@abdelrahmanadel8998 4 жыл бұрын
😂😂
@kakatuaOfficial
@kakatuaOfficial 4 жыл бұрын
Off Topic: I solved the first problem in Codejam 2020 in exactly 1 hour. The same time than Errichto... for all the problems.
@shahanahmed952
@shahanahmed952 4 жыл бұрын
That's impressive! How long have you been coding?
@kakatuaOfficial
@kakatuaOfficial 4 жыл бұрын
@@shahanahmed952 you should read the hidden comment. Errichto solved all the problems in 1 hour.
@shahanahmed952
@shahanahmed952 4 жыл бұрын
@@kakatuaOfficial Lmao did not notice that,Thanks mate.😅🤣
@BianLee
@BianLee 4 жыл бұрын
Great video but could u put face cam bottom left corner so we can read question better?
@Errichto
@Errichto 4 жыл бұрын
Damn, sorry about that. I will be more careful next time.
@gamarayburst1258
@gamarayburst1258 4 жыл бұрын
*How one can achieve speed like you in logic building? It seems you have a gift from God.*
@alexwindy3
@alexwindy3 4 жыл бұрын
He has been doing this for years and years...its like driving a car, he knows the streets by now.
@Errichto
@Errichto 4 жыл бұрын
Practice.
@Phsoco
@Phsoco 4 жыл бұрын
I think his process before even looking at the question gives you some insight there. He has done so many of these type of questions that he was predicting what it would be, so when the question appeared on the screen all he needed was a few key words and could immediately start typing. After doing a lot of practice you can take a cursory glance at a question and know what they are going to ask. This applies to everything, not just coding.
@parthbhatia341
@parthbhatia341 4 жыл бұрын
Is leetcode enough for interviews or do i have to do competetive programming.
@Errichto
@Errichto 4 жыл бұрын
You don't have to do CP for coding interviews. Leetcode is enough.
@Mrwiseguy101690
@Mrwiseguy101690 4 жыл бұрын
When you can't answer a hard leetcode problem in -5 seconds: 3:17
@FitnessChaos
@FitnessChaos 3 жыл бұрын
ayoooo what the fuck in the beginning lmfaooo
@tsatsralt9112
@tsatsralt9112 4 жыл бұрын
you are the beST!
@anupamnerbheram7464
@anupamnerbheram7464 2 жыл бұрын
Just by watching him doing Codding my IQ shoots up twice before.
@andrewfischer-garbutt2867
@andrewfischer-garbutt2867 4 жыл бұрын
I did this problem without knowing the algorithm in the video. My solution took more than 100 lines of code.
@Errichto
@Errichto 4 жыл бұрын
And this is why I said this is not a problem. Easy for half of people (because they know it), very hard for others.
@hacker-7214
@hacker-7214 4 жыл бұрын
lmaooooo
@limakbear7029
@limakbear7029 3 жыл бұрын
7:05 for me :p
@pyak6761
@pyak6761 3 жыл бұрын
i didnt kno kadanes algorithm. but thats like my entire interviewing life. fffff
@sahil3735
@sahil3735 4 жыл бұрын
Hello sir, can you suggest how is CLRS introduction to algorithm book.
@amanpratapsingh1243
@amanpratapsingh1243 4 жыл бұрын
Bible
@sahil3735
@sahil3735 4 жыл бұрын
@@amanpratapsingh1243 have you used it?
@Aditya-us5gj
@Aditya-us5gj 4 жыл бұрын
Well said Aman.
@Aditya-us5gj
@Aditya-us5gj 4 жыл бұрын
Yes Sahil ! It is bible. Will test every corner of your brain. If you complete that book properly, then you can say you've mastered DS and Algorithms along with high knowledge of mathematics.
@manavmohata1240
@manavmohata1240 4 жыл бұрын
You need good math skills to go through that book
@missilemahmood
@missilemahmood 3 жыл бұрын
10:52 Did he just say "daal bhat"? 🤣 He must have learned it from some Bangladeshi friend of his.
@limakbear7029
@limakbear7029 3 жыл бұрын
See caption., it's done, but
@LiangyueLi
@LiangyueLi 4 жыл бұрын
Thanks Errichto, could you use python for the demo? just wondering.
@Errichto
@Errichto 4 жыл бұрын
so far solutions are quite basic and I think everything is understandable for any programmer. I don't want to use Python because I risk doing something wrong and teaching you something incorrect.
@LiangyueLi
@LiangyueLi 4 жыл бұрын
@@Errichto Thanks Errichto, that makes sense. But if I want to participate in competitive programming like you mentioned in the other video, I should learn C++, right?
@richardj.rustleshyman2026
@richardj.rustleshyman2026 4 жыл бұрын
Zzzzzzzzzzzzz I was trying this without looking at the solution and after hours of smashing my head, I ended up with a triple-nested for loop method that wasn't even working properly Fml
@Gregory.Pacheco
@Gregory.Pacheco 4 жыл бұрын
This solution beats 95% of the other solutions: max_current, max_global = a[0], a[0] for i in range(1, len(a)): max_current = max(a[i], max_current + a[i]) max_global = max(max_current, max_global) return max_global
@srivatsanraghavan5996
@srivatsanraghavan5996 4 жыл бұрын
PLEASE MAKE A DAY IN LIFE. YOU WIL GET A MILLION VIEW
@saibhargavaramu5749
@saibhargavaramu5749 4 жыл бұрын
me all this time .. ka-da-ne
LeetCode Challenge Day 4 - First Good Problem?
9:17
Errichto Algorithms
Рет қаралды 43 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 343 М.
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 162 МЛН
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 38 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 79 МЛН
Cyber Threats Xposed - June 2024
49:00
WithSecure
Рет қаралды
Maximum Product Subarray - Dynamic Programming - Leetcode 152
15:31
Google Coding Interview With A Competitive Programmer
54:17
Clément Mihailescu
Рет қаралды 2,5 МЛН
Leetcode Biweekly #56 (2nd Place)
15:58
Errichto Algorithms
Рет қаралды 82 М.
Maximum Product Subarray - Best Intuitive Approach Discussed
20:27
take U forward
Рет қаралды 171 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Algorithms Lecture 13: Maximum Sub-array Problem using Divide-and-Conquer
18:40
Ghassan Shobaki Computer Science Lectures
Рет қаралды 78 М.