
刷题
Felomeng
Dreamer
展开
-
LeetCode Java First 400 题解-034
Search for a Range MediumGiven an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the o...原创 2019-11-20 13:08:55 · 412 阅读 · 0 评论 -
LeetCode Java First 400 题解-033
Search in Rotated Sorted Array MediumSuppose 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).You are giv...原创 2019-11-20 13:05:32 · 429 阅读 · 0 评论 -
LeetCode Java First 400 题解-032
Longest Valid Parentheses HardGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid pa...原创 2019-11-19 13:27:21 · 309 阅读 · 0 评论 -
LeetCode Java First 400 题解-031
Next Permutation MediumImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange...原创 2019-11-18 11:57:55 · 312 阅读 · 0 评论 -
LeetCode Java First 400 题解-030
Substring with Concatenation of All Words HardYou are given a string,s, and a list of words,words, that are all of the same length. Find all starting indices of substring(s) insthat is a conc...原创 2019-11-01 06:44:06 · 335 阅读 · 0 评论 -
LeetCode Java First 400 题解-029
Divide Two Integers MediumDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.public int divide(int dividend, int divisor) { if...原创 2019-11-01 06:43:25 · 276 阅读 · 0 评论 -
LeetCode Java First 400 题解-028
Implement strStr()EasyImplement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.public int strStr(String haystack, String ne...原创 2019-11-01 06:42:51 · 280 阅读 · 0 评论 -
LeetCode Java First 400 题解-027
Remove Element EasyGiven 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 must do this in place wit...原创 2019-11-01 06:42:20 · 282 阅读 · 0 评论 -
LeetCode Java First 400 题解-026
Remove Duplicates from Sorted Array EasyGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for an...原创 2019-11-01 06:41:45 · 332 阅读 · 0 评论 -
LeetCode Java First 400 题解-025
Reverse Nodes in k-Group HardGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.kis a positive integer and is less than or equal to the length of ...原创 2019-11-01 06:41:04 · 259 阅读 · 0 评论 -
LeetCode Java First 400 题解-024
Swap Nodes in Pairs MediumGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your...原创 2019-11-01 06:39:25 · 296 阅读 · 0 评论 -
LeetCode Java First 400 题解-023
Merge k Sorted Lists HardMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.public ListNode mergeKLists(ListNode[] lists) { if (lists == nul...原创 2019-11-01 06:38:46 · 247 阅读 · 0 评论 -
LeetCode Java First 400 题解-022
Generate Parentheses MediumGivennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:[ "((()))", ...原创 2019-11-01 06:38:17 · 347 阅读 · 0 评论 -
LeetCode Java First 400 题解-021
Merge Two Sorted Lists EasyMerge 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.public ListNode mergeTwo...原创 2019-11-01 06:37:41 · 253 阅读 · 0 评论 -
LeetCode Java First 400 题解-020
Valid Parentheses EasyGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"an...原创 2019-10-30 00:29:42 · 257 阅读 · 0 评论 -
LeetCode Java First 400 题解-019
Remove Nth Node From End of List MediumGiven 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 = ...原创 2019-10-30 00:28:59 · 291 阅读 · 0 评论 -
LeetCode Java First 400 题解-018
4Sum MediumGiven an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of target.Note:...原创 2019-10-30 00:27:46 · 367 阅读 · 0 评论 -
LeetCode Java First 400 题解-017
Letter Combinations of a Phone Number MediumGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telepho...原创 2019-10-30 00:26:55 · 229 阅读 · 0 评论 -
LeetCode Java First 400 题解-016
3Sum Closest MediumGiven 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 ...原创 2019-10-30 00:24:10 · 158 阅读 · 0 评论 -
LeetCode Java First 400 题解-015
3Sum MediumGiven 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...原创 2019-10-30 00:19:15 · 206 阅读 · 0 评论 -
LeetCode Java First 400 题解-014
Longest Common Prefix EasyWrite a function to find the longest common prefix string amongst an array of strings.public String longestCommonPrefix(String[] strs) { if (strs.length == 0)...原创 2019-10-30 00:17:08 · 153 阅读 · 0 评论 -
LeetCode Java First 400 题解-013
Roman to Integer EasyGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.public int romanToInt(String s) { int sum = 0; if (s....原创 2019-10-30 00:16:15 · 217 阅读 · 0 评论 -
LeetCode Java First 400 题解-012
Integer to Roman MediumRoman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50...原创 2019-10-30 00:04:40 · 231 阅读 · 0 评论 -
LeetCode Java First 400 题解-011
Container With Most Water MediumGivennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of line...原创 2019-10-30 00:03:32 · 206 阅读 · 0 评论 -
LeetCode Java First 400 题解-010
Regular Expression Matching HardGiven an input string (s) and a pattern (p), implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches ze...原创 2019-10-26 13:15:09 · 204 阅读 · 0 评论 -
LeetCode Java First 400 题解-009
Palindrome Number EasyDetermine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting ...原创 2019-10-26 13:00:20 · 191 阅读 · 0 评论 -
LeetCode Java First 400 题解-008
String to Integer (atoi) MediumImplementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yours...原创 2019-10-26 12:48:54 · 225 阅读 · 0 评论 -
LeetCode Java First 400 题解-007
Reverse Integer EasyReverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are some good question...原创 2019-10-26 12:43:13 · 223 阅读 · 0 评论 -
LeetCode Java First 400 题解-006
ZigZag Conversion MediumThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility...原创 2019-10-26 11:22:24 · 144 阅读 · 0 评论 -
LeetCode Java First 400 题解-005
Longest Palindromic Substring MediumGiven a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example:Input: "babad"Output: "bab"...原创 2019-10-23 12:37:35 · 237 阅读 · 0 评论 -
LeetCode Java First 400 题解-004
Median of Two Sorted Arrays HardThere are two sorted arraysnums1andnums2of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(lo...原创 2019-10-23 12:36:47 · 232 阅读 · 0 评论 -
LeetCode Java First 400 题解-003
Longest Substring Without Repeating Characters MediumGiven a string, find the length of thelongest substringwithout repeating characters.Examples:Given"abcabcbb", the answer is"abc", whic...原创 2019-10-23 12:27:25 · 219 阅读 · 0 评论 -
LeetCode Java First 400 题解 - 002
Add Two Numbers MediumYou are given twonon-emptylinked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add t...原创 2019-10-23 12:18:27 · 225 阅读 · 0 评论 -
LeetCode Java First 400 题解-001
Two sumGiven an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use ...原创 2019-10-22 11:44:39 · 294 阅读 · 0 评论