Rising Diagonal
grid is square: it has n rows and n columns. Return the values on the diagonal that rises from the bottom-left corner to the top-right corner, in that order: the first value is grid[n - 1][0] and the last value is grid[0][n - 1].
Example 1
grid [[1,2,3],[4,5,6],[7,8,9]]
returns [7,5,3]
The cells are grid[2][0] = 7, grid[1][1] = 5 and grid[0][2] = 3.
Example 2
grid [[1,2],[3,4]]
returns [3,2]
Bottom-left is 3, top-right is 2.
Constraints
1 <= n <= 10-100 <= grid[r][c] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Grids problems
- Snake ReadBeginner
- Spot the DifferencesBeginner
- Square on a Winding BoardBeginner
- Colony StepEasy
- Diagonal BandsEasy
- Fenced RobotEasy
- Is It the TransposeEasy
- Island PerimeterEasy