首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏SnailTyan

    Triangle

    Solution class Solution { public: int minimumTotal(vector<vector<int>>& triangle) { int n = triangle.size(); vector<int> sums(triangle[n -1]); for(int i = n - 2; i >= 0; i--) { for(int j = 0; j <= i; j++) { sums[j] = min(sums[j], sums[j + 1]) + triangle

    44010发布于 2019-05-25
  • 来自专栏calmound

    Pascals Triangle

    问题:输出杨辉三角 分析:对于每一行收尾都等于1,其他位置f[i,j]=f[i-1,j-1]+f[i-1,j] class Solution { public: vector<vector<int> > generate(int numRows) { int i,j; if(numRows==0) { return vector<vector<int> >(); } vector<vector<i

    54950发布于 2018-04-17
  • 来自专栏给永远比拿愉快

    Leetcode: Triangle

    题目: Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum : int minimumTotal(vector<vector<int> > &triangle) { int row = triangle.size(); if (row == 0) return 0; vector<int> dp(row); // 初始化dp容大小为triangle最后一行数据的个数 for (size_t i = 0; i < row; ++i) { dp[i] = triangle[row - 1][i]; // dp初始化为triangle的最后一行

    52520发布于 2019-01-22
  • 来自专栏calmound

    The Triangle

    从顶到底的最大和是多少 #include<stdio.h> #include<string.h> int main() { int n,i,j; int a[110][100]; int sum[110]; int ans; while(scanf("%d",&n)!=EOF) { for (i=0;i<n;i++) { for(j=0;j<=i;j++) {

    584100发布于 2018-04-11
  • 来自专栏米扑专栏

    【leetcode】Triangle

    Question: Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] Anwser 1: .size(); j++) { triangle[i][j] += min(triangle[i+1][j], triangle[i+1][j+1 return; } run(triangle, row + 1, idx, curSum + triangle[row][idx], minPath); run(triangle, row + 1, idx + 1, curSum + triangle[row][idx], minPath); } int minimumTotal

    45120发布于 2019-02-19
  • 来自专栏程序编程之旅

    POJ 1163 The Triangle

    The Triangle Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total Submission The first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the triangle. The number of rows in the triangle is > 1 but <= 100. The numbers in the triangle, all integers, are between 0 and 99.

    32740发布于 2021-01-19
  • 来自专栏算法修养

    LeetCode 120 Triangle

    Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle The minimum path sum from top to bottom is 11 (i.e., 2 + 3 ) { int len = triangle.size(); dp[0][0] = triangle[0][0]; for(int i= { if(j==0) dp[i][j] = triangle[i][j]+dp[i-1][j]; dp[i][j] = min(triangle[i][j]+dp[i-1][j],triangle[i][j]+dp[i-1][j-1]); } }

    37910发布于 2018-07-24
  • 来自专栏Reck Zhang

    LeetCode 0120 - Triangle

    Triangle Desicription Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum Solution class Solution { public: int minimumTotal(vector<vector<int>>& triangle) { for(int i = triangle.size()-2; i >= 0; i--) { for(int j = 0; j <= i; j++) { triangle [i][j] += min(triangle[i+1][j], triangle[i+1][j+1]); } } return triangle[

    23210发布于 2021-08-11
  • 来自专栏专注研发

    poj-1163-The Triangle

    Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure 1 shows a number triangle The first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the triangle. The number of rows in the triangle is > 1 but <= 100. The numbers in the triangle, all integers, are between 0 and 99.

    51420发布于 2018-09-21
  • 来自专栏计算机视觉与深度学习基础

    Leetcode 118 Pascals Triangle

    Given numRows, generate the first numRows of Pascal's triangle.

    57970发布于 2018-01-12
  • 来自专栏给永远比拿愉快

    Leetcode: Pascals Triangle II

    题目: Given an index k, return the kth row of the Pascal’s triangle.

    38620发布于 2019-01-22
  • 来自专栏米扑专栏

    【leetcode】Pascals Triangle II

    Question: Given an index k, return the kth row of the Pascal's triangle.

    39530发布于 2019-02-19
  • 来自专栏Reck Zhang

    LeetCode 0118 - Pascals Triangle

    Pascal’s Triangle Desicription Given numRows, generate the first numRows of Pascal’s triangle.

    25330发布于 2021-08-11
  • 来自专栏饶文津的专栏

    【UVA 11401】Triangle Counting

    以i 为最大边,第二边为i-1、i-2、...2 的三角形分别有 i-2个、i-3、... 、1个,总共就有(i-1)*(i-2)/2个。有(i-1)/2条边算到了两边相等,也就是要减去 (i-1)/2,因为第二边的在第三边出现了,所以算了两次,再除以2。

    34410发布于 2020-06-02
  • 来自专栏米扑专栏

    【leetcode】Pascals Triangle

    Question:       Given numRows, generate the first numRows of Pascal's triangle.

    31430发布于 2019-02-19
  • 来自专栏计算机视觉与深度学习基础

    Leetcode 120 Triangle

    Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle class Solution { public: int minimumTotal(vector<vector<int>>& triangle) { vector<vector< int>> dp=triangle; for(int i=1;i<dp.size();i++) { for(int j=0;j<dp[i].size

    56850发布于 2018-01-12
  • 来自专栏Zaqdt_ACM

    NYOJ 18 The Triangle

           动态规划问题,题意是输入一个数字三角形,然后从上往下走一条路,问走到底端的最大值。如果从上往下走的话会有很多种情况,所以不如反过来从下往上递推,比较大小求最大值。

    32610发布于 2019-01-10
  • 来自专栏calmound

    Pascals Triangle II

    问题:输出杨辉三角的第n行 class Solution { public: vector<int> getRow(int rowIndex) { vector<int> vec; int a[100][100]; a[0][0]=1; int j,i; for(i=1;i<=rowIndex;i++) { a[i][0]=1; for(j=1;j<i;j+

    51370发布于 2018-04-17
  • 来自专栏来自地球男人的部落格

    Triangle

    【原题】 Given a triangle, find the minimum path sum from top to bottom. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum 代码如下: public class Solution { public int minimumTotal(List<List<Integer>> triangle) { int m =triangle.size(); //int n=triangle[0].length;//刚开始还想申请二维数组来着 int[] dp=new int[m+1]; for(int i=m-1;i>=0;i--){ List<Integer> row=triangle.get(i); for(int j=0;j<row.size

    57970发布于 2018-01-03
  • 来自专栏给永远比拿愉快

    Leetcode: Pascals Triangle

    题目: Given numRows, generate the first numRows of Pascal's triangle.

    40430发布于 2019-01-22
领券