Learning is a bit daunting when books don't explain why are you learning this particular thing.
In my early years I had been fortunate to have teachers who actually took out time to feed that curiosity, and explain why we were learning anything.
Be it calculus (which we use in reality to calculate how infinitesimal small force--additive or otherwise, can impact anything) or statistic which we need to visualize details about customers in real life.
If you can visualize one real time use case, learning becomes easier, it makes us feel that us learning something would actually help us contribute towards something in future.
Let's move towards algorithms now, specifically arrays today.
We know arrays are used to store contiguous memory but why do need the related algorithms?
Few of the must needed algorithms that you must have come across are --
- Kadane's algorithm
- Linear Search
- Binary Search
- Dutch National Flag
- Prefix and Suffix sum
- Sliding Window
- Two Pointer Technique
- Precomputation Covering corner cases, and the other types of arrays like sparse, jagged, 2D, frequency, etc are also needed. in our day to day solutions. We will start with where Kadane's algorithm is used in real life - its applications include buying and selling stocks, in genomic sequences analysis, as well as image processing etc. The intuition behind it is to find the maximum sum of a contiguous subarray in an array. It gives us an optimal solution in O(n) therefore it is one of the most efficient algorithms. Below are few of the questions that can be solved using Kadane's algorithm :
- Maximim Subarray
- Best time to buy/sell stocks
- Maximum Product Subarray
https://leetcode.com/problems/maximum-score-of-spliced-array/
https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray/
https://leetcode.com/problems/maximum-subarray-sum-after-one-operation/
https://leetcode.com/problems/substring-with-largest-variance/
https://leetcode.com/problems/count-subarrays-with-score-less-than-k/
https://leetcode.com/problems/maximum-value-of-a-string-in-an-array/
https://leetcode.com/problems/find-the-substring-with-maximum-cost/
Top comments (0)