leetcode
学习leetcode中的算法
修炼中的菜鸟
这个作者很懒,什么都没留下…
展开
-
38-Count and Say
题目描述:https://leetcode.com/problems/count-and-say/The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 11...原创 2019-06-30 16:51:53 · 433 阅读 · 0 评论 -
37-Sudoku Solver
题目描述:https://leetcode.com/problems/sudoku-solver/Write a program to solve a Sudoku puzzle by filling the empty cells.Asudoku solution must satisfyall ofthe following rules:Each of the digit...原创 2019-06-30 16:16:43 · 494 阅读 · 0 评论 -
36-Valid Sudoku
题目描述:Determine if a9x9 Sudoku boardis valid.Only the filled cells need to be validatedaccording to the following rules:Each rowmust contain thedigits1-9without repetition. Each column mus...原创 2019-06-30 10:13:09 · 393 阅读 · 0 评论 -
35-Search Insert Position
题目描述:https://leetcode.com/problems/search-insert-position/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 in...原创 2019-06-30 10:08:24 · 493 阅读 · 0 评论 -
34-Find First and Last Position of Element in Sorted Array
题目描述:https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/Given an array of integersnumssorted in ascending order, find the starting and ending position of a giv...原创 2019-06-30 10:03:24 · 395 阅读 · 0 评论 -
33-Search in Rotated Sorted Array
题目描述:https://leetcode.com/problems/search-in-rotated-sorted-array/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 becom...原创 2019-06-30 09:58:23 · 322 阅读 · 0 评论 -
32-Longest Valid Parentheses
题目描述:https://leetcode.com/problems/longest-valid-parentheses/Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.E...原创 2019-05-04 20:41:25 · 376 阅读 · 0 评论 -
31-Next Permutation
题目描述:题目地址:https://leetcode.com/problems/next-permutation/Implementnext permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement i...原创 2019-05-04 14:41:01 · 330 阅读 · 0 评论 -
30-Substring with Concatenation of All Words
题目描述: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) insthat is a concatenation of each word inwordsexactly once...原创 2019-05-04 14:13:59 · 322 阅读 · 0 评论 -
29-Divide Two Integers
题目描述:https://leetcode.com/problems/divide-two-integers/Given two integersdividendanddivisor, divide two integers without using multiplication, division and mod operator.Return the quotient af...原创 2019-05-04 14:08:44 · 320 阅读 · 0 评论 -
28-implement-strstr
题目描述: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 = "hello", needle = "ll"Output: 2...原创 2018-11-05 22:24:57 · 974 阅读 · 0 评论 -
27-remove-element
题目描述:Your function should return length = 2, with the first two elements of nums being 2.It doesn't matter what you leave beyond the returned length.Example 2:Given nums = [0,1,2,2,3,0,4,2]...原创 2018-11-05 21:53:07 · 326 阅读 · 0 评论 -
26-remove-duplicates-from-sorted-array
题目描述: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 another array, you must do this by ...原创 2018-11-05 21:30:21 · 293 阅读 · 0 评论 -
25-reverse-nodes-in-k-group
题目描述: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 length of the linked list. If the num...原创 2018-11-04 22:10:43 · 337 阅读 · 0 评论 -
24-swap-nodes-in-pairs
题目描述: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.Note:Your algorithm should u...原创 2018-11-04 20:54:07 · 304 阅读 · 0 评论 -
23-merge-k-sorted-lists
题目描述: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]Output: 1->1->2->3...原创 2018-11-04 11:54:16 · 385 阅读 · 0 评论 -
22-generate-parentheses
题目描述: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-04 10:58:18 · 363 阅读 · 0 评论 -
21-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.Example:Input: 1->2->4, 1->3->4Out...原创 2018-11-02 23:31:47 · 929 阅读 · 0 评论 -
20-valid-parentheses
题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same ty...原创 2018-11-02 20:59:36 · 307 阅读 · 0 评论 -
19-remove-nth-node-from-end-of-list
题目描述: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 removing the second node from the...原创 2018-11-01 22:48:54 · 921 阅读 · 0 评论 -
18-4sum
题目描述: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 in the array which gives the sum...原创 2018-11-01 21:41:20 · 224 阅读 · 0 评论 -
17-letter-combinations-of-a-phone-number
题目描述: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 (just like on the telephone buttons)...原创 2018-10-31 22:21:33 · 807 阅读 · 0 评论 -
14-longest-common-prefix
题目描述: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:Input: ["flower","flow","flight"]...原创 2018-10-28 19:39:56 · 248 阅读 · 0 评论 -
15-3sum
题目描述: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.Note:The solution set must n...原创 2018-10-28 22:42:54 · 176 阅读 · 0 评论 -
16-3sum-closest
题目描述: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 integers. You may assume that each input...原创 2018-10-30 21:31:37 · 300 阅读 · 0 评论 -
13-roman-to-integer
题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-10-28 13:33:42 · 336 阅读 · 0 评论 -
12-integer-to-roman
题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-10-28 12:18:26 · 261 阅读 · 0 评论 -
11-container-with-most-water
题目描述:Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). F...原创 2018-10-26 22:54:43 · 466 阅读 · 0 评论 -
10-regular-expression-matching
题目描述:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding ele...原创 2018-10-26 20:20:46 · 347 阅读 · 0 评论 -
9-palindrome-number
题目描述:Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseE...原创 2018-10-24 20:24:07 · 250 阅读 · 0 评论 -
7-reverse-integer
题目描述:Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are deali...原创 2018-10-23 22:05:53 · 503 阅读 · 1 评论 -
8-string-to-integer-atoi
题目描述:Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting f...原创 2018-10-23 23:43:21 · 479 阅读 · 1 评论 -
3-longest-substring-without-repeating-characters
题目:Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example ...原创 2018-10-20 17:33:56 · 268 阅读 · 0 评论 -
4-median-of-two-sorted-arrays
题目描述: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 complexity should be O(log (m+n)).You may assume nums...原创 2018-10-20 19:20:13 · 284 阅读 · 0 评论 -
5-Longest Palindromic Substring
题目描述:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer....原创 2018-10-21 08:57:41 · 190 阅读 · 0 评论