
【LeetCode】
goto456
这个作者很懒,什么都没留下…
展开
-
【LeetCode】3. Longest Substring Without Repeating Characters - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc...原创 2018-07-24 22:25:13 · 696 阅读 · 0 评论 -
【LeetCode】12. Integer to Roman - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D...原创 2018-11-18 11:07:16 · 303 阅读 · 0 评论 -
【LeetCode】13. Roman to Integer - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D...原创 2018-11-18 11:27:02 · 871 阅读 · 0 评论 -
【LeetCode】14. Longest Common Prefix - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Inpu...原创 2018-11-18 11:40:39 · 457 阅读 · 0 评论 -
【LeetCode】26. Remove Duplicates from Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for ano...原创 2018-11-24 12:34:27 · 568 阅读 · 0 评论 -
【LeetCode】22. Generate Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))...原创 2018-11-23 08:24:25 · 463 阅读 · 0 评论 -
【LeetCode】16. 3Sum Closest - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integer...原创 2018-11-18 15:14:32 · 433 阅读 · 0 评论 -
【LeetCode】15. 3Sum - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero...原创 2018-11-18 12:51:19 · 418 阅读 · 0 评论 -
【LeetCode】27. Remove Element - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you m...原创 2018-11-24 15:02:08 · 332 阅读 · 0 评论 -
【LeetCode】29. Divide Two Integers - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividen...原创 2018-11-28 22:58:40 · 1143 阅读 · 0 评论 -
【LeetCode】28. Implement strStr() - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hell...原创 2018-11-26 23:15:45 · 538 阅读 · 0 评论 -
【LeetCode】30. Substring with Concatenation of All Words - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:You 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) in s that is a concatenation o...原创 2018-12-03 22:21:04 · 646 阅读 · 0 评论 -
【LeetCode】31. Next Permutation - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it mus...原创 2018-12-04 08:22:04 · 553 阅读 · 0 评论 -
【LeetCode】32. Longest Valid Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Ou...原创 2018-12-09 14:38:00 · 686 阅读 · 0 评论 -
【LeetCode】33. Search in Rotated Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are giv...原创 2018-12-09 21:54:55 · 389 阅读 · 0 评论 -
【LeetCode】34. Find First and Last Position of Element in Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity mu...原创 2018-12-16 11:52:33 · 1022 阅读 · 0 评论 -
【LeetCode】35. Search Insert Position - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You m...原创 2018-12-16 12:11:13 · 771 阅读 · 0 评论 -
【LeetCode】18. 4Sum - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets...原创 2018-11-20 08:07:05 · 567 阅读 · 0 评论 -
【LeetCode】17. Letter Combinations of a Phone Number - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (jus...原创 2018-11-20 07:24:35 · 405 阅读 · 0 评论 -
【LeetCode】1. Two Sum - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input wo...原创 2018-07-13 18:21:33 · 270 阅读 · 0 评论 -
【LeetCode】2. Add Two Numbers - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a s...原创 2018-07-13 18:23:28 · 562 阅读 · 0 评论 -
【LeetCode】5. Longest Palindromic Substring - Java实现
1. 题目描述:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example: Input: “babad” Output: “bab” Note: “aba” is also a va...原创 2018-07-28 19:09:36 · 751 阅读 · 0 评论 -
【LeetCode】4. Median of Two Sorted Arrays - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time co...原创 2018-07-28 19:04:05 · 757 阅读 · 0 评论 -
【LeetCode】6. ZigZag Conversion - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:The 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 fo...原创 2018-07-28 21:38:10 · 472 阅读 · 0 评论 -
【LeetCode】7. Reverse Integer - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a 32-bit signed integer, reverse digits of an integer.Example 1: Input: 123 Output: 321Example 2: Input: -123 Output: -321...原创 2018-07-29 13:57:06 · 464 阅读 · 0 评论 -
【LeetCode】9. Palindrome Number - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExampl...原创 2018-11-12 23:23:17 · 498 阅读 · 0 评论 -
【LeetCode】8. String to Integer (atoi) - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace char...原创 2018-11-11 18:08:50 · 529 阅读 · 0 评论 -
【LeetCode】10. Regular Expression Matching - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.‘.’ Matches any single character.‘*’ Matches ...原创 2018-11-14 08:30:31 · 343 阅读 · 0 评论 -
【LeetCode】19. Remove Nth Node From End of List - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After rem...原创 2018-11-21 08:22:05 · 453 阅读 · 0 评论 -
【LeetCode】11. Container With Most Water - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given n non-negative integers a[1], a[2], …, a[n] , where each represents a point at coordinate (i, a[i]). n vertical lines are drawn such that the two endpoint...原创 2018-11-15 08:23:41 · 244 阅读 · 0 评论 -
【LeetCode】20. Valid Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open bracke...原创 2018-11-22 07:44:02 · 838 阅读 · 0 评论 -
【LeetCode】21. Merge Two Sorted Lists - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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.Example:Input: 1...原创 2018-11-22 07:50:08 · 521 阅读 · 0 评论 -
【LeetCode】23. Merge k Sorted Lists - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]...原创 2018-11-23 22:20:55 · 548 阅读 · 0 评论 -
【LeetCode】24. Swap Nodes in Pairs - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a linked list, swap every two adjacent nodes and return its head.Example:Given 1->2->3->4, you should return the list as 2->1->4->3....原创 2018-11-24 10:15:45 · 656 阅读 · 0 评论 -
【LeetCode】25. Reverse Nodes in k-Group - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the lengt...原创 2018-11-24 10:23:36 · 759 阅读 · 0 评论 -
【LeetCode】36. Valid Sudoku - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 wit...原创 2018-12-17 22:05:48 · 570 阅读 · 0 评论