In this article I would like to introduce Angular framework to beginners who are just getting started. This article will serve only as an introduction and further explanations and concepts of Angular will be publlished in my next few articles.
Angular is a framework for building mobile and web based…
Imagine you are the owner of a coffee shop. You have a cashier who takes orders from customers and a barista who prepares the coffee. Now, what if there are a few customers who want to give orders directly to the barista? It disturbs the barista who focuses on brewing…
This problem is similar to “Search a 2D matrix”, the solution to which I have written in my previous article. If you have read the previous article, read the problem description and continue to the efficient solution.
Given a triangle array, return the minimum path sum from top to bottom.
For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row.
If you are at an index “i” in a row, you can move to index “i” or index “i+1” in the next row. So, the minimum value for an index “i” in a row can be obtained by considering index “i-1” or index “i” from the previous row. So, the original triangle matrix is modified top down considering the minimum values from the previous row. Finally, we return the minimum value from the last row.