Hi folks! Today, I solved three problems on LeetCode: Jump Game, Triangle, and Min Stack. In both the Jump Game and Triangle problems, we have to find an efficient logic to solve them. In the Min Stack problem, we need to use the stack data structure. Always make sure to review the problems you’ve completed at least once a week. This will help you connect previously learned concepts with newly learned ones.
To solve the Jump Game problem, we traverse through the input array, keeping track of the farthest index we can reach. If we can reach or exceed the last index of the input array, we return true. Otherwise, we return false.
To solve the Triangle problem, we can use nested for loops to traverse the triangle and find the minimum element at each level. We add these minimum elements to get the sum. This is how we can solve this problem.
To solve the Min Stack problem, we can implement a stack and create methods like push, pop, top, and get Min. This approach helps us solve the problem efficiently.
I hope my experience will be helpful to you!
Source link
lol