Not slding window problem

it is not a sliding window problem

Lesson: Best Time to Buy and Sell Stock - Grokking Coding Interview Patterns in Python

Hey @Sardor

I understand that you may have a different perspective on the problem, which made us look at it again. However, after careful consideration and analysis, we still believe a variation of the sliding window technique can efficiently solve this problem.

The use of two pointers, left and right, to iterate through the prices list, where the window defined by these pointers can expand and shrink depending on the subset of the array being considered, is a key characteristic of the dynamic sliding window technique. The dynamic nature of the window allows us to efficiently find the maximum difference between any two elements such that the larger element comes after the smaller element, which is the key to solving the problem.

It is great that you are already coming up with alternate solutions and brainstorming different techniques so early in the course. This shows that you are actively engaged and motivated to explore different options and find the best solution, which is what we intended with the challenge-only lessons in the course.

I encourage you to also consider the sliding window technique as one of the options and try solving the problem with it. Please let me know if you have any further questions or concerns.

Happy Learning :smiley:

1 Like