![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
[leetcode]
UFO_good
这个作者很懒,什么都没留下…
展开
-
[Array]Combination Sum III
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Input: k = 3, n =原创 2016-07-21 13:00:58 · 354 阅读 · 0 评论 -
[Array]Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct原创 2016-07-13 09:19:56 · 248 阅读 · 0 评论 -
[Array]Rotate Array
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].方法1:将k%size进行处理后将最后面k个插入到前面。class Solution { public:原创 2016-07-08 12:47:12 · 234 阅读 · 0 评论 -
[Array]Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The order原创 2016-06-29 08:25:26 · 276 阅读 · 0 评论 -
[Array] Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2016-07-14 09:07:36 · 229 阅读 · 0 评论 -
[Array]Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example: Given nums = [2, 7, 11原创 2016-07-02 21:45:03 · 218 阅读 · 0 评论 -
[Array]Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combination.No原创 2016-07-21 12:58:26 · 288 阅读 · 0 评论 -
[Array]Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of t原创 2016-07-21 12:56:38 · 254 阅读 · 0 评论 -
[Array]Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return 0 instead.For example, given the array [2,3,1,2,4,原创 2016-07-21 08:59:32 · 226 阅读 · 0 评论 -
[Array]Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in that case原创 2016-07-21 08:43:36 · 258 阅读 · 0 评论 -
[Array]Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always原创 2016-07-13 08:55:24 · 262 阅读 · 0 评论 -
[Array]Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional原创 2016-07-09 14:37:11 · 226 阅读 · 0 评论 -
[Array]Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is原创 2016-07-07 23:36:41 · 277 阅读 · 0 评论 -
[Array]Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.思路:利用unorde原创 2016-07-07 13:05:43 · 202 阅读 · 0 评论 -
[Array]3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly原创 2016-07-18 08:32:43 · 201 阅读 · 0 评论 -
[Array] Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons原创 2016-07-15 10:45:14 · 591 阅读 · 0 评论 -
[Array]Pascal's Triangle II
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space?方法:在每一行的更新中,从后往前进行更新可以使代码原创 2016-07-15 08:41:21 · 291 阅读 · 0 评论 -
[Array] Pascal's Triangle
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] ] 方法:正常模拟即可。class Solution { pu原创 2016-07-15 08:30:56 · 262 阅读 · 0 评论