Kadane's Algorithm - Maximum Subarray (Dynamic Programming)

Pubblicato il: 21 aprile 2021
sul canale di: AlgosWithMichael
31,554
892

Maximum subarray is a popular LeetCode interview questions asked at Microsoft, Amazon, Apple, LinkedIn, ByteDance, Google, Adobe, and several other top tech companies. This problem is solved in the most efficient way using dynamic programming with an algorithm known as Kadane's algorithm.

Kadane's algorithm finds a contiguous subarray with the largest sum in linear time. Using this algorithm, as we iterate through our array, we compute the max subarray at each step using the following recurrence relation; current is equal to the max between the current and the current plus the previous. Since we overwrite the formula values with the array we are given, the algorithm provides a constant space complexity in addition to the linear time complexity.

Check out my interview prep platform for learning the patterns!
📢 Interview Prep Platform: https://algoswithmichael.com

🔗 Social 🔗
🎧 Join the community Discord:   / discord  
💰 Support me on Patreon:   / michaelmuinos  
🔗Follow me on LinkedIn:   / michael-muinos  
📂Follow me on Github: https://github.com/MichaelMuinos


In questa pagina del sito puoi guardare il video online Kadane's Algorithm - Maximum Subarray (Dynamic Programming) della durata di ore minuti seconda in buona qualità , che l'utente ha caricato AlgosWithMichael 21 aprile 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 31,554 volte e gli è piaciuto 892 spettatori. Buona visione!