自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(93)
  • 收藏
  • 关注

原创 LeetCode 90. Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,2], a solutio

2017-07-24 04:27:41 316

原创 LeetCode 89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2017-07-24 03:13:18 209

原创 LeetCode 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 additio

2017-07-24 02:56:49 206

原创 LeetCode 87.Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr

2017-07-16 02:44:55 394

原创 LeetCode 86. Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of t

2017-07-16 01:47:17 355

原创 LeetCode 85. Maximal Rectangle

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 matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1

2017-07-15 21:50:06 219

原创 LeetCode 84. Largest Rectangle in Histogram

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 histogram.Above is a histogram where width of ea

2017-07-15 17:32:12 160

原创 LeetCode 83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.链表去重,比上一题简单很多,两个指针就够了

2017-07-15 14:21:20 134

原创 LeetCode 82. Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->

2017-07-15 02:14:13 408

原创 LeetCode 81. Search in Rotated Sorted Array II

Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose an array sorted in ascending order is rotated at

2017-07-14 00:09:20 172

原创 LeetCode 80. Remove Duplicates from Sorted Array II

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 should return length = 5, with the first fi

2017-07-13 22:17:15 122

原创 LeetCode 79. Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically

2017-07-13 18:19:59 157

原创 LeetCode 78. Subsets

Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1], [

2017-07-13 01:26:55 285

原创 LeetCode 77. Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]

2017-07-11 13:22:50 163

原创 LeetCode 76. Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN

2017-07-11 01:31:52 237

原创 LeetCode 75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0,

2017-07-10 02:10:27 295

原创 LeetCode 74. Search a 2D Matrix

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 from left to right.The first integer of each

2017-07-10 02:10:07 187

原创 LeetCode 73. Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.用额外空间去记录一下哪个位置出现了0,一个记录行,一个记录列,碰到这两个索引之一直接置0import java.util.ArrayList;

2017-07-09 19:22:16 210

原创 LeetCode 72. Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2017-07-09 18:43:46 146

原创 LeetCode 71. Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"简化unix的路径符号,/..是返回上一级,/.是保持当前目录,需要做的就是字符串的判断,要有equals来

2017-07-09 16:47:20 158

原创 LeetCode 70. Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi

2017-07-09 14:22:49 105

原创 LeetCode 69. Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.实现开方功能,第一个想到的就是二分法,注意的是,为了防止溢出,需要用除法比较而不是乘法public class Solution { public int mySqrt(int x) { if(x<2)return x;

2017-07-09 02:27:02 135

原创 LeetCode 68. Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that i

2017-07-08 19:28:21 133

原创 LeetCode 67. Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路和两个链表相加很像,最后记得要判断flag是否有进位public class Solution { public String addBin

2017-07-08 01:37:52 260

原创 leetcode 66. Plus One

Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digi

2017-07-05 21:36:59 168

原创 leetcode 65. Valid Number

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo

2017-07-05 20:47:21 173

原创 leetcode 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2017-07-05 16:42:00 129

原创 leetcode 63. Unique Paths II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2017-07-05 16:22:04 98

原创 leetcode 62. Unique Paths

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 point in time. The robot is trying to reach the bo

2017-07-05 15:30:04 117

原创 leetcode 61. Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.题意是把一个链表的最后k个元素放到表头首先要遍历一遍链表,得到

2017-07-05 13:24:55 119

原创 leetcode 60. Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3

2017-07-04 20:25:36 129

原创 leetcode 59. Spiral Matrix II

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [

2017-07-03 23:36:23 150

原创 leetcode 58. Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2017-07-03 23:12:57 121

原创 leetcode 57. Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E

2017-07-03 22:37:31 156

原创 leetcode 56. Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].这个题的难点在于,怎么去对Interval类型进行排序,在屡次失败之后,在别人的博客学到了,

2017-07-03 21:01:59 124

原创 leetcode 55. Jump Game

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i

2017-07-03 19:55:10 120

原创 leetcode 54. Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]

2017-07-03 18:06:18 103

原创 leetcode 53. Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] ha

2017-07-03 17:10:09 126

原创 leetcode 52. N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.这个和上一道题没什么区别,最后返回size就好public class Solution { public int totalNQ

2017-07-03 16:08:01 102

原创 leetcode 51. N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Eac

2017-07-03 15:48:12 121

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

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