![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
青城小语
这个作者很懒,什么都没留下…
展开
-
27. Remove Element
27. Remove Element先排序再记录下val的起始位置,然后把val之后的其它元素填入val的位置代码int removeElement(vector<int>& nums, int val) { if (nums.empty()) { return 0; } sort(nums.begin(), nums.end()); int原创 2017-12-23 18:52:06 · 192 阅读 · 0 评论 -
119. Pascal’s Triangle II
119. Pascal’s Triangle II杨辉三角,主要是要在O(n)的空间复杂度实现 如果直接用组合数公式推导,阶乘计算会溢出 所以还是逐行递推下去,不过每次都从末尾开始更新,因为ans[j]=ans[j]+ans[j-1],不会擦除掉下一个要用的数据,再处理下边界就行。代码vector<int> getRow(int rowIndex) { if (rowIndex == 0原创 2017-12-23 18:09:01 · 317 阅读 · 0 评论 -
62. Unique Paths
题目描述 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 try原创 2018-01-26 13:42:42 · 227 阅读 · 0 评论 -
442. Find All Duplicates in an Array
题目描述 Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it原创 2018-01-26 14:42:31 · 199 阅读 · 0 评论 -
718. Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays. Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7] Output: 3 Explanation: The原创 2018-01-27 13:59:23 · 228 阅读 · 0 评论