
LeetCode
文章平均质量分 92
RyanWang0000
这个作者很懒,什么都没留下…
展开
-
LeetCode.2:Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2019-03-20 18:16:53 · 126 阅读 · 0 评论 -
LeetCode-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) is give...原创 2019-05-08 15:55:15 · 192 阅读 · 0 评论 -
LeetCode.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 not contai...原创 2019-05-06 10:51:01 · 108 阅读 · 0 评论 -
LeetCode.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 type of br...原创 2019-05-13 22:50:58 · 105 阅读 · 0 评论 -
LeetCode.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->4->...原创 2019-05-19 22:46:32 · 109 阅读 · 0 评论 -
LeetCode-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 would ...原创 2019-05-07 16:20:32 · 154 阅读 · 0 评论 -
LeetCode.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 of tar...原创 2019-05-10 14:42:44 · 111 阅读 · 0 评论 -
LeetCode.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 end, the ...原创 2019-05-10 16:19:32 · 121 阅读 · 0 评论 -
LeetCode.24: Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed.思路:非递归,重指针操作用三个指针不停的变换位置来交换结点,需仔细理解,想了好久,推...原创 2019-05-20 22:43:59 · 133 阅读 · 0 评论 -
LeetCode.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->4Output: 1->...原创 2019-05-16 16:55:14 · 161 阅读 · 0 评论 -
LeetCode.27:Remove Element
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 must do this by modifying the input array...原创 2019-05-25 20:04:41 · 117 阅读 · 0 评论 -
LeetCode.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 number of n...原创 2019-05-22 10:31:52 · 108 阅读 · 0 评论 -
LeetCode.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 modifyin...原创 2019-05-23 09:57:54 · 93 阅读 · 0 评论 -
LeetCode.63:Unique Paths II【DP】
A robot is located at the top-left corner of a m x n grid (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 bot...原创 2019-04-24 16:42:34 · 172 阅读 · 0 评论 -
LeetCode.62:Unique Paths【DP】
A robot is located at the top-left corner of a m x n grid (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 bot...原创 2019-04-24 15:57:02 · 161 阅读 · 0 评论 -
LeetCode.70:Climbing Stairs【DP】
You are climbing a stair case. It takes n steps 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?Note: Given n will be a positive i...原创 2019-04-24 15:22:23 · 105 阅读 · 0 评论 -
LeetCode.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 nums1 and num...原创 2019-03-25 16:34:10 · 174 阅读 · 0 评论 -
LeetCode.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 2:Inpu...原创 2019-03-22 13:20:32 · 151 阅读 · 0 评论 -
LeetCode.6: ZigZag Conversion
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 font for better legibility)P A H NA P L S I I G...原创 2019-03-29 21:23:03 · 160 阅读 · 0 评论 -
LeetCode.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.Example...原创 2019-03-26 21:36:03 · 113 阅读 · 0 评论 -
LeetCode.7: ReverseInteger
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 dealing with ...原创 2019-04-10 15:42:19 · 149 阅读 · 0 评论 -
LeetCode.8:StringtoInteger(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 from this...原创 2019-04-11 13:20:09 · 139 阅读 · 0 评论 -
LeetCode.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: falseExplanatio...原创 2019-04-12 15:54:37 · 140 阅读 · 0 评论 -
LeetCode.10:Regular Expression Matching【DP】
Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The ...原创 2019-04-21 12:47:12 · 122 阅读 · 0 评论 -
LeetCode.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). Find two l...原创 2019-04-26 14:48:08 · 137 阅读 · 0 评论 -
LeetCode.12、13:Integer to Roman、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 ...原创 2019-04-27 19:55:04 · 129 阅读 · 0 评论 -
LeetCode.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"]Output: "fl...原创 2019-04-28 21:07:12 · 158 阅读 · 0 评论 -
LeetCode.53:Maximum Subarray【DP】
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation:...原创 2019-04-24 14:59:47 · 194 阅读 · 0 评论 -
LeetCode.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:[ "((()))", "(()())", "(())()", "()(())", ...原创 2019-05-18 13:51:09 · 113 阅读 · 0 评论