Description 正在上传…取消Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each s
题目: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [[2],[3,4],[6,5,7],[4,1
119. Pascal’s Triangle II Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it
题目 Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths. If it is impossible to form any triangle of non-zero area, ret
题目: Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1]. 思路: 要求是返回帕斯卡某一行的数据设置两个list变量,pre和next,pre用来存储当前的最后的最后一行,next存储下一行,next赋值给pre(在这之前pre清空,
题目: Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] 思路 题意是要用数组表示帕斯卡三角形输入一个数值,显示相应行数的【帕斯卡三角形根据下一行和上一行
题意: 一个小球在一个等边三角形内碰撞,碰撞速度不比,方向沿边镜像翻折。求发送 k k k次碰撞需要多少时间 思路: 一开始想着是模拟,然后估摸着最后会形成循环,经过起始点。但是太难模拟了。。 看了题解发现,真的特别巧妙。反射意味着穿过!那么就成了全是等边三角形铺成的平面,已知起点和速度。求经过 k k k条边的最短时间。 这个时间可以二分。 仅考虑平行x轴的边,那就直接用 a b s ⌊
Little Sub is about to take a math exam at school. As he is very confident, he believes there is no need for a review. Little Sub’s father, Mr.Potato, is nervous about Little Sub’s attitude, so he gi
题意: 现在有一个multiset,每次有三种操作: 1 x 往multiset里塞一个x 2 x 删掉multiset里的一个x 3 x 询问是否能从multiset中找出两个数使得他们和x能够构成一个非退化三角形 题解: 那么这道题我一看他就是个权值线段树,但是由于一些小bug,我调了几个小时,最后靠着队友的强力对拍才找到。。。太难了 首先我们知道对于操作3,有两种情况: 1.x是最大