
Leetcode
NeoJoe
人生没有闲,只有临阵逃脱
展开
-
220. Contains Duplicate III
MediumGiven an array of integers, find out whether there are two distinct indicesiandjin the array such that theabsolutedifference betweennums[i]andnums[j]is at mosttand theabsolutediff...原创 2019-05-01 19:22:10 · 298 阅读 · 0 评论 -
347. Top K Frequent Elements
MediumGiven a non-empty array of integers, return thekmost frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]...原创 2019-07-08 22:12:28 · 276 阅读 · 0 评论 -
215. Kth Largest Element in an Array
Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5E...原创 2019-07-08 21:35:04 · 216 阅读 · 0 评论 -
373. Find K Pairs with Smallest Sums
MediumYou are given two integer arraysnums1andnums2sorted in ascending order and an integerk.Define a pair(u,v)which consists of one element from the first array and one element from the se...原创 2019-05-01 13:51:22 · 298 阅读 · 0 评论 -
239. Sliding Window Maximum
Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window mo...原创 2019-05-01 10:29:55 · 135 阅读 · 0 评论 -
164. Maximum Gap
HardGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Return 0 if the array contains less than 2 elements.Example 1:Input: [3,6,9,1]Outp...原创 2019-05-01 08:52:16 · 209 阅读 · 0 评论 -
89. Gray Code
MediumThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequen...原创 2019-04-30 18:50:34 · 160 阅读 · 0 评论 -
372. Super Pow
MediumYour task is to calculateabmod 1337 whereais a positive integer andbis an extremely large positive integer given in the form of an array.Example 1:Input: a = 2, b = [3]Output: 8...原创 2019-04-30 15:58:32 · 170 阅读 · 0 评论 -
233. Number of Digit One
HardGiven an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.Example:Input: 13Output: 6 Explanation: Digit 1 occurred in the follow...转载 2019-04-30 13:40:44 · 289 阅读 · 0 评论 -
274. H-Index
MediumGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to thedefinition of h-index on Wikipedi...原创 2019-04-30 10:28:06 · 189 阅读 · 0 评论 -
96. Unique Binary Search Trees
MediumGivenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1...原创 2019-04-29 20:10:05 · 118 阅读 · 0 评论 -
295. Find Median from Data Stream
HardMedian is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.For example,[2,3,4], th...原创 2019-04-29 18:37:56 · 196 阅读 · 0 评论 -
146. LRU Cache
Design and implement a data structure forLeast Recently Used (LRU) cache. It should support the following operations:getandput.get(key)- Get the value (will always be positive) of the key if th...原创 2019-04-29 16:18:44 · 136 阅读 · 0 评论 -
493. Reverse Pairs
HardGiven an arraynums, we call(i, j)animportant reverse pairifi < jandnums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:I...原创 2019-05-01 21:52:12 · 188 阅读 · 0 评论 -
322. Coin Change
You are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money ...原创 2019-07-21 21:26:01 · 257 阅读 · 0 评论