Maximum Subarray | Kadane's Algorithm | Leetcode 53

  Рет қаралды 11,894

Technosage

Technosage

Күн бұрын

Maximum Subarray | Kadane's Algorithm
Leetcode problem number 53
Time Complexity: O(n)
Space Complexity: O(1)
JAVA interview programming playlist:
• Interview Programming ...
#java #interviewquestions #leetcode

Пікірлер: 20
@bsv1511
@bsv1511 Жыл бұрын
What should happen if all elements in the array are negative?
@faizuddin4032
@faizuddin4032 8 ай бұрын
If all elements are negative then the sum will also be negative number
@saarza9991
@saarza9991 6 ай бұрын
Bro 1st complete ur 5th standard 😂
@nitikarajpoot9869
@nitikarajpoot9869 Ай бұрын
@@saarza9991 aapke pita ji jadge h nhi n to jadzment ku de rhe ho bhai
@VaibhavGupta-iu4uf
@VaibhavGupta-iu4uf Ай бұрын
@@faizuddin4032 no bro if all elements are negative the sum will be negative but she applied a condition that whenever the sum becomes negative we mark it as zero as we will not count it
@VaibhavGupta-iu4uf
@VaibhavGupta-iu4uf Ай бұрын
@@nitikarajpoot9869 yar itni funny baatein kaise kr leti hain ladkiyan
@harishm3683
@harishm3683 Жыл бұрын
Waiting for FST 7 & ArthurJones / Mike Menzter's Heavy duty training style master !
@KarmakillsYou
@KarmakillsYou Жыл бұрын
Please continue this series. Also, please explain the time and space complexity concepts in this series. It will be helpful for FAANG interview preparation.
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Sure ,Will make a video on time and space complexity soon
@RahulBhatia-py1iv
@RahulBhatia-py1iv 4 күн бұрын
Thanks mam
@ez1ogod
@ez1ogod Жыл бұрын
Doesn't work when every element is negative. Bruhhhhh!!!
@TechnosageLearning
@TechnosageLearning Жыл бұрын
So here mathematics comes into picture. For negative number the lagest would be just a single number. For example if array= [-2,-3,-1] here largest sum would be -1, because -1 is the only largest number here!!
@gowthamganesh2974
@gowthamganesh2974 9 ай бұрын
but we are setting (sum = 0) if the sum is negative then how it take negative elements?? According the given code : i=0 where a[0] = -2 sum = -2 maxsum = -2 then sum = 0 i = 1 where a[1] = -3 sum = -3 maxsum = -2 then sum = 0 i = 2 where a[2] = -1 sum = -1 maxsum = -2 sum = 0 So were are getting -2 as maxsum!@@TechnosageLearning
@Aditya-pm9fb
@Aditya-pm9fb 7 ай бұрын
Before u set the value of sum to 0 u check in the if condition whether the sum > max_sum or not that's where the max_sum gets updated to -1 coz at the end u return max_sum only.@@gowthamganesh2974
@Aditya-pm9fb
@Aditya-pm9fb 7 ай бұрын
Before u update the sum variable u check if sum > max_sum thats where the variable gets updated.@@gowthamganesh2974
@eUREKAA11
@eUREKAA11 6 ай бұрын
​@@gowthamganesh2974 you are wrong here. At i = 2, Max sum will be -1 because ( -1 > -2) hence maxSum = -1
@Omkar-fg4ws
@Omkar-fg4ws 6 ай бұрын
xavier
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 445 М.
Spongebob ate Patrick 😱 #meme #spongebob #gmod
00:15
Mr. LoLo
Рет қаралды 21 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 69 МЛН
ЭТО НАСТОЯЩАЯ МАГИЯ😬😬😬
00:19
Chapitosiki
Рет қаралды 3,7 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 406 М.
Maximum Product Subarray - Best Intuitive Approach Discussed
20:27
take U forward
Рет қаралды 215 М.
Subarray Sum Equals K - Prefix Sums - Leetcode 560 - Python
15:19
Kadane's Algo in 16 minutes || Algorithms for Placements
16:58
CodeHelp - by Babbar
Рет қаралды 197 М.
Kadane's Algorithm to Maximum Sum Subarray Problem
11:17
CS Dojo
Рет қаралды 713 М.
Spongebob ate Patrick 😱 #meme #spongebob #gmod
00:15
Mr. LoLo
Рет қаралды 21 МЛН