程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> LeetCode | Unique Paths

LeetCode | Unique Paths

編輯:C++入門知識

題目

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

How many possible unique paths are there?

\

Above is a 3 x 7 grid. How many pZ喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vc3NpYmxlIHVuaXF1ZSBwYXRocyBhcmUgdGhlcmU/PC9wPgo8cD4KTm90ZTogbSBhbmQgbiB3aWxsIGJlIGF0IG1vc3QgMTAwLjwvcD4KPHN0cm9uZz631s72PC9zdHJvbmc+CjxwPtK71tbLvMK3vs3Kx7avzKy55ruuo6zB7dK71ta+zcrHx/PX6brPyv1DKG4mIzQzO20tMiwgbS0xKaOsx/PX6brPyv27ubXD0KHQxNLns/aho9XiwO+4+LP2tcTKx7avzKy55ruutcS94reooaM8L3A+CjxwPjxzdHJvbmc+tPrC6zwvc3Ryb25nPjwvcD4KPHA+PHByZSBjbGFzcz0="brush:java;">public class UniquePaths { public int uniquePaths(int m, int n) { int[] dp = new int[n]; // init dp[0] = 1; // dp for (int i = 0; i < m; ++i) { for (int j = 1; j < n; ++j) { dp[j] += dp[j - 1]; } } return dp[n - 1]; } }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved