Hello everyone!
Day 3 of Week 11 introduces a series of sliding window and prefix sum techniques, which are two powerful tools for optimizing array problems. Today’s tasks require tracking accumulated data and leveraging it for effective decision-making. It feels like sailing through a dynamic landscape, adjusting and optimizing along the way.
How did the day go?
-
Find the highest altitude (easy difficulty)
- Given a set of gain values, calculate the highest altitude reached during the journey.
-
Strategy:
- Use the prefix sum method to track the cumulative height of each step.
- Maintain running max to determine maximum altitude.
-
The interesting part:
- Watching the altitude dynamically rise and fall with each gain value feels like you’re on a true journey through peaks and valleys.
-
Finding Pivot Index (Easy Difficulty)
- Finds the pivot index of the array where the sum of the elements on the left is equal to the sum of the elements on the right.
-
Strategy:
- Calculate the sum of the array and iterate over it, keeping the left sum running.
- At each index, check whether the left sum is equal to the sum minus the current element and the left sum.
-
The interesting part:
- Finding the balance is like balancing the seesaw perfectly – it pays to see the logical consistency.
what makes today special
-
Prefix total power:
- Both problems demonstrate the efficiency of prefix sums in tracking cumulative information for fast calculations.
-
Optimize through clarity:
- Tasks such as Find pivot index Emphasizes the importance of breaking down problems into logical components to achieve elegant solutions.
-
Visual dynamics:
- Tracking height changes and equilibrium points makes the problem intuitive and engaging, adding a layer of practical understanding.
focus
Reflection
this Find the highest altitude The problem is a simple but satisfying application of prefix sums, while Find pivot index Its equilibrium conditions add a layer of complexity. Together, these tasks emphasize the importance of cumulative data tracking and logical problem decomposition in solving array challenges.
What’s next?
I will solve it tomorrow Hashmap/set probleminclude Find the difference between two arrays and unique occurrences. These tasks will test my ability to utilize hash-based structures for efficient data management.
Thank you for your attention! Let’s keep solving, learning, and growing together.