LeetCode 283. Move Zeroes(java)

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, giv...

2018-01-30 15:06:55

阅读数:28

评论数:0

LeetCode 80. Remove Duplicates from Sorted Array II(java)

Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function s...

2018-01-30 14:50:46

阅读数:24

评论数:0

LeetCode 26. Remove Duplicates from Sorted Array(java)

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 fo...

2018-01-30 14:34:54

阅读数:20

评论数:0

LeetCode 27. Remove Element(java)

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 ...

2018-01-30 13:47:29

阅读数:31

评论数:0

LeetCode 62. Unique Paths(java)

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 p...

2018-01-27 11:00:54

阅读数:31

评论数:0

LeetCode 312. Burst Balloons(java)

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloo...

2018-01-27 10:46:05

阅读数:44

评论数:0

LeetCode 218. The Skyline Problem(java)

A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are giv...

2018-01-27 08:41:31

阅读数:72

评论数:0

LeetCode 204. Count Primes(java)

Description:Count the number of prime numbers less than a non-negative number, n.解法一:每次判断i是不是prime,然后用一个dp[]数组来存结果,然后由于每次都要判断prime的时间太长,所以被TLE了。时间复杂度...

2018-01-26 09:24:49

阅读数:34

评论数:0

LeetCode 240. Search a 2D Matrix II(java)

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted i...

2018-01-26 08:49:16

阅读数:32

评论数:0

LeetCode 406. Queue Reconstruction by Height(java)

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the per...

2018-01-26 08:29:30

阅读数:29

评论数:0

LeetCode 279. Perfect Squares(java)

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, r...

2018-01-26 07:20:27

阅读数:39

评论数:0

LeetCode 448. Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] ...

2018-01-26 06:32:42

阅读数:18

评论数:0

LeetCode 142. Linked List Cycle II(java)

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can yo...

2018-01-25 12:08:31

阅读数:27

评论数:0

非比较排序之桶排序(bucket sort)

1. 桶排序如果输入的数组里没有重复,那么一个普通数组就可以,这个数组的大小为原数组中的max - min + 1。代码如下。public static int[] bucketSort(int[] nums) { if (nums.length <= 1) return n...

2018-01-25 08:27:45

阅读数:38

评论数:0

LeetCode 347. 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 as...

2018-01-25 07:09:30

阅读数:48

评论数:0

LeetCode 95. Unique Binary Search Trees II

Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should ...

2018-01-25 03:08:43

阅读数:20

评论数:0

LeetCode 96. Unique Binary Search Trees(java)

Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST's...

2018-01-24 07:54:50

阅读数:19

评论数:0

LeetCode 85. Maximal Rectangle(java)

Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following...

2018-01-23 06:45:56

阅读数:35

评论数:0

LeetCode 84. Largest Rectangle in Histogram(java)

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the his...

2018-01-22 09:44:12

阅读数:22

评论数:0

LeetCode 221. Maximal Square(java)

Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.For example, given the following ma...

2018-01-22 08:24:22

阅读数:35

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭