自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode- trapping-rain-water

Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given[0,1,0,2,1,0,1,3,2,1,2,1], re...

2019-05-31 20:14:10 266

原创 LeetCode-multiply-strings

Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. public class Solution { public Strin...

2019-05-31 20:12:23 257

原创 LeetCode- wildcard-matching

Implement wildcard pattern matching with support for'?'and'*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the...

2019-05-31 20:10:16 240

原创 LeetCode-jump-game-ii

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. Your goal is to...

2019-05-31 20:08:33 247

原创 LeetCode- permutations

Given a collection of numbers, return all possible permutations. For example, [1,2,3]have the following permutations: [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1]. import java.util.*; publ...

2019-05-31 20:07:00 188

原创 LeetCode-permutations-ii

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2]have the following unique permutations: [1,1,2],[1,2,1], and[2,1,1]. import...

2019-04-09 23:38:49 183

原创 LeetCode-rotate-image

You are given annxn2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? public class Solution { public void rotate(int[][] ma...

2019-04-09 23:36:50 132

原创 LeetCode-anagrams

Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. import java.util.*; public class Solution { public ArrayList<String> ana...

2019-04-09 23:35:16 226

原创 LeetCode-powx-n

Implement pow(x,n). public class Solution { public double pow(double x, int n) { if (n == 0) return 1.0; double half = pow(x, n/2); if (n%2 == 0) { return half*h...

2019-04-09 23:34:13 155

原创 LeetCode-n-queens

Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other. Given an integern, return all distinct solutions to then-queens puzzle. Eac...

2019-04-09 23:32:41 177

原创 LeetCode-n-queens-ii

public class Solution { public int totalNQueens(int n) { switch (n){ case 0:return 1; case 1:return 1; case 2:return 0; case 3:return 0; ...

2019-04-09 23:31:09 151

原创 LeetCode-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]has the ...

2019-04-09 23:30:00 135

原创 LeetCode-spiral-matrix

Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You sh...

2019-04-08 23:47:43 114

原创 LeetCode- 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 if yo...

2019-04-08 23:46:31 188

原创 LeetCode-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]. /** * Definition for an interval. * public class Interv...

2019-04-08 23:45:15 154

原创 LeetCode-insert-interval

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

2019-04-08 23:44:07 125

原创 LeetCode-length-of-last-word

Given a stringsconsists 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 define...

2019-04-08 22:32:29 124

原创 LeetCode-spiral-matrix-ii

Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order. For example, Givenn=3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7...

2019-04-08 22:30:59 150

原创 LeetCode-permutation-sequence

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

2019-04-08 22:29:41 171

原创 LeetCode-rotate-list

Given a list, rotate the list to the right bykplaces, wherekis non-negative. For example: Given1->2->3->4->5->NULLandk=2, return4->5->1->2->3->NULL. /** * Defin...

2019-04-08 22:28:36 121

原创 LeetCode-unique-paths

A robot is located at the top-left corner of amxngrid (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...

2019-04-07 23:03:24 923

原创 LeetCode-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 as1and0respectively in the grid. For...

2019-04-07 23:01:42 757

原创 LeetCode-minimum-path-sum

Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path. Note:You can only move either down or right at a...

2019-04-07 22:09:40 158

原创 LeetCode-merge-two-sorted-lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. /** * Definition for singly-linked list. * public clas...

2019-04-07 22:08:02 182

原创 LeetCode-add-binary

Given two binary strings, return their sum (also a binary string). For example, a ="11" b ="1" Return"100". public class Solution { public String addBinary(String a, String b) { char[] ...

2019-04-06 22:38:41 212

原创 LeetCode-valid-number

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

2019-04-06 22:37:33 148

原创 LeetCode-plus-one

Given a number represented as an array of digits, plus one to the number. import java.util.*; public class Solution { public static int[] plusOne(int[] digits) { ArrayList<Int...

2019-04-06 22:17:35 202

原创 LeetCode-text-justification

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

2019-04-06 22:16:12 132

原创 LeetCode-sqrtx

Implementint sqrt(int x). Compute and return the square root ofx. public class Solution { public int sqrt(int x) { long r = x; while(r*r>x) r = (r+x/r)/2; ...

2019-04-06 22:14:34 123

原创 LeetCode- climbing-stairs

You are climbing a stair case. It takesnsteps 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? public class Solution { pub...

2019-04-06 22:13:16 150

原创 LeetCode-simplify-path

Given an absolute path for a file (Unix-style), simplify it. For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c" click to show corner cases. Corner Cases: Did you consider t...

2019-04-06 22:08:48 122

原创 LeetCode-edit-distance

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

2019-04-06 13:01:30 169

原创 LeetCode-set-matrix-zeroes

Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(mn) s...

2019-04-06 13:00:14 98

原创 LeetCode-search-a-2d-matrix

Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row...

2019-04-06 12:59:12 225

原创 LeetCode-sort-colors

Given an array withnobjects 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,...

2019-04-05 21:59:57 292

原创 LeetCode-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"BANC". Note: I...

2019-04-05 21:58:54 235

原创 LeetCode-combinations

Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n. For example, Ifn= 4 andk= 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] ...

2019-04-05 21:57:38 255

原创 LeetCode-subsets

Given a set of distinct integers,S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example, If...

2019-04-05 21:56:29 187

原创 LeetCode- 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 n...

2019-04-05 21:55:06 224

原创 LeetCode-remove-duplicates-from-sorted-array-ii

Follow up for "Remove Duplicates": What if duplicates are allowed at mosttwice? For example, Given sorted array A =[1,1,1,2,2,3], Your function should return length =5, and A is now[1,1,2,2,3]. i...

2019-04-05 20:05:09 126

空空如也

空空如也

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

TA关注的人

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