
LeetCode
文章平均质量分 67
creeew
这个作者很懒,什么都没留下…
展开
-
220. Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference ...原创 2018-03-16 10:43:40 · 209 阅读 · 0 评论 -
151. Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-place in O(1) space.cl...原创 2018-03-11 22:09:10 · 154 阅读 · 0 评论 -
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, and you may not use the same el...原创 2018-03-12 11:24:49 · 183 阅读 · 0 评论 -
697. Degree of an Array
Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length of a (c...原创 2018-03-12 15:47:28 · 161 阅读 · 0 评论 -
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 element is...原创 2018-03-13 19:27:55 · 147 阅读 · 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 absolute difference between i and j is at most k.其...原创 2018-03-13 20:30:50 · 291 阅读 · 0 评论 -
Top K Frequent Elements Java
Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elemen...原创 2018-03-30 22:28:23 · 247 阅读 · 0 评论 -
Majority Element II (Moore vote algorithm
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.题目要我们在大小为n的数组中找出所有出现次数大于n/3的数。既然是要大于n/3则一个数组中就只能最多有2个...原创 2018-03-31 11:06:48 · 239 阅读 · 0 评论 -
695. Max Area of Island(dfs)
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrou...原创 2018-04-14 22:29:38 · 186 阅读 · 0 评论