Problem C. Minimum Path in Triangle
The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.
Given a triangle array. The bird starts at the top, and for each step, it can move either left or right down (if it is on the index j
at the current row, it can move to j
or j+1
position on the next row). Return the minimum path cost among all possible paths from top to bottom.
Example 1
The orange path is minimum and costs 12.
Example 2
Input: triangle
= [[1],
[2, 1],
[8, 3, 7],
[5, 2, 6, 1]]
Output: 7
Explanation: The path looks like:
Swipe to start coding
Implement a function minPath()
for triangle
array.
- Find the rule for shortest path in
triangle[i][j]
. - Define the rule for corner cases.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Vat dit hoofdstuk samen
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 8.33
Problem C. Minimum Path in Triangle
Veeg om het menu te tonen
The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.
Given a triangle array. The bird starts at the top, and for each step, it can move either left or right down (if it is on the index j
at the current row, it can move to j
or j+1
position on the next row). Return the minimum path cost among all possible paths from top to bottom.
Example 1
The orange path is minimum and costs 12.
Example 2
Input: triangle
= [[1],
[2, 1],
[8, 3, 7],
[5, 2, 6, 1]]
Output: 7
Explanation: The path looks like:
Swipe to start coding
Implement a function minPath()
for triangle
array.
- Find the rule for shortest path in
triangle[i][j]
. - Define the rule for corner cases.
Oplossing
Bedankt voor je feedback!
Awesome!
Completion rate improved to 8.33single