![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode整理 Array
StudyCoder
这个作者很懒,什么都没留下…
展开
-
217. 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 ele转载 2016-05-07 19:56:12 · 226 阅读 · 0 评论 -
169. 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转载 2016-05-06 13:55:36 · 283 阅读 · 0 评论 -
121. 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 th转载 2016-05-06 11:38:50 · 317 阅读 · 0 评论 -
26. 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 pla转载 2016-05-06 10:47:00 · 284 阅读 · 0 评论 -
219. 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 jis at most转载 2016-05-05 15:20:34 · 318 阅读 · 0 评论 -
88. 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 add转载 2016-05-05 15:04:45 · 261 阅读 · 0 评论 -
66. Plus One
Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 题目大意 给定一个转载 2016-05-05 11:54:14 · 283 阅读 · 0 评论 -
27. 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.转载 2016-05-05 10:51:53 · 243 阅读 · 0 评论 -
119. 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? Subscrib转载 2016-05-04 16:49:44 · 262 阅读 · 0 评论 -
283. 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 you转载 2016-05-04 15:18:10 · 336 阅读 · 0 评论 -
2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link转载 2016-05-04 11:17:18 · 272 阅读 · 0 评论 -
1. 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 =转载 2016-05-02 12:51:44 · 249 阅读 · 0 评论 -
118. 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] ] 题意: 给出层数,生成杨辉三角。转载 2016-05-07 21:05:06 · 279 阅读 · 0 评论 -
189. 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]. Note: Try to come up as many soluti转载 2016-05-07 10:18:44 · 201 阅读 · 0 评论