Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Problem C. Minimum Path in Triangle | Problems
Dynamic Programming
course content

Contenido del Curso

Dynamic Programming

Dynamic Programming

1. Intro to Dynamic Programming
2. Problems
3. Solutions

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:

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 3
toggle bottom row

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:

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 3
toggle bottom row

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:

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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:

Tarea

Implement a function minPath() for triangle array.

  1. Find the rule for shortest path in triangle[i][j].
  2. Define the rule for corner cases.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt