- 博客(148)
- 收藏
- 关注
转载 [LeetCode] 19. Remove Nth Node From End of List Java
题目:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node...
2018-02-27 15:08:00
219
转载 [LeetCode] 16. 3Sum Closest Java
题目:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have...
2018-02-27 12:29:00
245
转载 [LeetCode] 15. 3Sum Java
题目:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not...
2018-02-27 12:02:00
205
转载 [LeetCode] 11. Container With Most Water Java
题目:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). F...
2018-02-27 10:35:00
183
转载 [LeetCode] 3.Longest Substring Without Repeating Characters
题目:Given a string, find the length of thelongest substringwithout repeating characters.Examples:Given"abcabcbb", the answer is"abc", which the length is 3.Given"bbbbb", the answer ...
2018-02-26 10:03:00
82
转载 [LeetCode] 50. Pow(x, n) Java
题目:Implementpow(x,n).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100题意及分析:实现求x的n次方,使用分治法,复杂度降低到log2n代码:public class Solution { ...
2018-01-23 12:40:00
288
转载 [LeetCode] 45. Jump Game II Java
题目: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 ...
2018-01-23 09:41:00
113
转载 [LeetCode] 57. Insert Interval Java
题目: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 tim...
2018-01-18 10:23:00
150
转载 [LeetCode] 54. Spiral Matrix Java
题目: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, ...
2018-01-15 15:08:00
101
转载 [LeetCode] 59. Spiral Matrix II Java
题目: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, ...
2018-01-15 14:39:00
98
转载 [LeetCode] 61. Rotate List Java
题目:Given a list, rotate the list to the right bykplaces, wherekis non-negative.Example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL....
2018-01-10 09:20:00
108
转载 [LeetCode] 67. Add Binary Java
题目:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".题意及分析:求两个用字符串表示 的二进制数的和。主要是判断每次相加的和是否大于2,大于2便进1取余。代码:class Solution { ...
2018-01-09 09:02:00
99
转载 [LeetCode] 65. Valid Number Java
题目: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 b...
2018-01-08 19:47:00
159
转载 [LeetCode] 66. Plus One Java
题目:Given a non-negative integer represented as anon-emptyarray of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.Th...
2018-01-08 16:01:00
118
转载 排序算法 Java
//1、冒泡排序 public void bubbleSort(int[] arr){ for(int i=0;i<arr.length;i++){ for(int j=0;j<arr.length-i-1;j++){ if(arr[j] > arr[j+1]){ ...
2018-01-07 15:11:00
89
转载 [LeetCode] 71. Simplify Path Java
题目:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"题意及分析:给出一个unix的绝对路径,简化路径,.表示当前目录,../表示上级目录。使用一个S...
2017-12-22 11:00:00
113
转载 [LeetCode] 72. Edit Distance Java
题目: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...
2017-12-22 10:12:00
119
转载 [LeetCode] 73. Set Matrix Zeroes Java
题目:iven 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 ...
2017-12-21 14:37:00
102
转载 [LeetCode] 75. Sort Colors Java
题目: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 i...
2017-12-21 09:37:00
106
转载 [Java] 80. Remove Duplicates from Sorted Array II Java
题目:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should return length =5, with the first ...
2017-12-19 09:45:00
147
转载 [LeetCode] 81. Search in Rotated Sorted Array II
题目:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Write a function to determine if a given ta...
2017-12-18 10:32:00
88
转载 [LeetCode] 83. Remove Duplicates from Sorted List Java
题目:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2-&g...
2017-12-17 21:46:00
67
转载 [LeetCode] 82. Remove Duplicates from Sorted List II [Java]
题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, retu...
2017-12-17 21:44:00
75
转载 [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 matrix:1 0 1 0 01 0 1 1 11 1 1 1...
2017-12-16 20:42:00
98
转载 [LeetCode] 84. Largest Rectangle in Histogram Java
题目:Givennnon-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 wid...
2017-12-16 19:54:00
85
转载 [LeetCode] 86. Partition List Java
题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in...
2017-12-16 10:28:00
84
转载 [LeetCode] 87. Scramble String Java
题目:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / ...
2017-12-15 20:26:00
97
转载 [LeetCode] 88. Merge Sorted Array Java
题目:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is greater or equal tom+n) to hold...
2017-12-10 21:26:00
63
转载 [LeetCode] 92. Reverse Linked List II Java
题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL...
2017-12-07 09:37:00
89
转载 [LeetCode] 93. Restore IP Addresses Java
题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.255.11.135", "255.255.111.35"]. (Or...
2017-12-06 10:02:00
82
转载 [Leetcode] 97. Interleaving String Java
题目:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", retur...
2017-12-03 20:43:00
85
转载 [LeetCode] 99. Recover Binary Search Tree Java
题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you d...
2017-12-01 12:04:00
68
转载 [LeetCode] 115. Distinct Subsequences Java
题目:Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT.A subsequence of a string is a new string which is formed from the original string by deletin...
2017-11-21 10:30:00
75
转载 字符串匹配算法(KMP&Sunddy) Java
KMP算法和Sunday算法代码:/** * Created by LXY on 2017/11/13. */public class KMP { public int KMP(String source,String target){ int i=0,j=0; int sSource = source.lengt...
2017-11-14 09:57:00
92
转载 [LeetCode ] 76. Minimum Window Substring Java
题目:给定一个字符串source和一个目标字符串target,在字符串source中找到包括所有目标字符串字母的子串。注意事项如果在source中没有这样的子串,返回"",如果有多个这样的子串,返回起始位置最小的子串。说明在答案的子串中的字母在目标字符串中是否需要具有相同的顺序?——不需要。样例给出sour...
2017-11-13 11:15:00
116
转载 [LeetCode] 119. Pascal's Triangle II Java
题目:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(k) extra space?题意及分析:求杨辉三角的...
2017-11-10 11:10:00
97
转载 [LeetCode] 118. Pascal's Triangle Java
题目:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]题意及分析:给出一个杨...
2017-11-10 10:22:00
70
转载 [LeetCode] 124. Binary Tree Maximum Path Sum Java
题目:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connectio...
2017-11-01 14:28:00
64
转载 [LeetCode] 125. Valid Palindrome Java
题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isno...
2017-11-01 10:46:00
129
转载 [LeetCode] 126. Word Ladder II Java
题目:Given two words (beginWordandendWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWordtoendWord, such that:Only one letter can be changed at...
2017-11-01 10:14:00
105
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人