
leetcode
随时学丫
越努力越幸运
展开
-
【Leetcode】344. Reverse String
344. Reverse StringEasyWrite a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by **modif...原创 2020-04-15 14:36:09 · 177 阅读 · 0 评论 -
【Leetcode】541. Reverse String II
541. Reverse String IIEasyGiven a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characte...原创 2020-04-15 14:36:16 · 242 阅读 · 0 评论 -
【Leetcode】557. Reverse Words in a String III
557. Reverse Words in a String IIIEasyGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:...原创 2020-04-15 14:36:23 · 300 阅读 · 0 评论 -
【Leetcode】657. Robot Return to Origin
657. Robot Return to OriginEasyThere is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its mo...原创 2020-04-15 14:36:34 · 177 阅读 · 0 评论 -
【Leetcode】1221. Split a String in Balanced Strings
1221. Split a String in Balanced StringsEasyBalanced strings are those who have equal quantity of ‘L’ and ‘R’ characters.Given a balanced string s split it in the maximum amount of balanced strings...原创 2020-04-14 09:48:37 · 195 阅读 · 0 评论 -
【Leetcode】686. Repeated String Match
686. Repeated String MatchEasyGiven two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.For example, with A =...原创 2020-04-14 09:48:01 · 156 阅读 · 0 评论 -
【Leetcode】459. Repeated Substring Pattern
459. Repeated Substring PatternEasyGiven a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the giv...原创 2020-04-15 14:37:12 · 178 阅读 · 0 评论 -
【Leetcode】1108. Defanging an IP Address
1108. Defanging an IP AddressEasy183503ShareGiven a valid (IPv4) IP address, return a defanged version of that IP address.A defanged IP address replaces every period "." with "[.]".Example 1:Inp...原创 2020-04-15 14:37:21 · 187 阅读 · 0 评论 -
【Leetocde】5. Longest Palindromic Substring
题目给定一个字符串 s,在 s 中找到最长的回文子串,s 的最大长度是 1000。题目难度:中等描述MediumGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "baba...原创 2020-04-15 14:37:31 · 148 阅读 · 0 评论 -
【Leetcode】26. Remove Duplicates from Sorted Array
##【Leetcode】26. Remove Duplicates from Sorted Array26.Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)EasyGiven a sorted array nums, remove t...原创 2020-04-14 09:44:05 · 229 阅读 · 0 评论 -
【Leetcode】53. Maximum Subarray
53. Maximum SubarrayGiven 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],O...原创 2020-04-15 14:38:10 · 234 阅读 · 0 评论 -
【Leetcode】628. Maximum Product of Three Numbers
628. Maximum Product of Three NumbersGiven an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6Example 2:Input: [1,2,3,...原创 2020-04-15 14:38:22 · 352 阅读 · 0 评论 -
【Leetcode】152. Maximum Product Subarray
152. Maximum Product SubarrayGiven an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Out...原创 2020-04-15 14:38:29 · 314 阅读 · 0 评论 -
【Leetcode】198. House Robber
198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is t...原创 2020-04-15 14:38:36 · 398 阅读 · 0 评论 -
【Leetcode】213. House Robber II
213. House Robber IIYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That mean...原创 2020-04-14 09:41:19 · 268 阅读 · 0 评论 -
【Leetcode】156. Merge Intervals
156. Merge IntervalsDescriptionGiven a collection of intervals, merge all overlapping intervals.ExampleGiven intervals => merged intervals:[ [ (1, 3), (1, 6...原创 2020-04-15 14:37:44 · 445 阅读 · 0 评论 -
【Leetcode】62. Search in Rotated Sorted Array
62. Search in Rotated Sorted ArrayYou are given a target value to search. If found in the array return its index, otherwise return -1.You may assume no duplicate exists in the array.ExampleFor [4,...原创 2020-04-14 09:40:16 · 148 阅读 · 0 评论 -
【Leetcode】100. Remove Duplicates from Sorted Array
100. Remove Duplicates from Sorted ArrayDescriptionGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space...原创 2020-04-14 09:39:44 · 211 阅读 · 0 评论 -
【Leetcode】479. Second Max of Array
479. Second Max of ArrayFind the second max number in a given array.NoticeYou can assume the array contains at least two numbers.ExampleGiven [1, 3, 2, 4], return 3.Given [1, 2], return 1.思路:从数...原创 2020-04-14 09:39:13 · 181 阅读 · 0 评论 -
【Leetcode】88. Merge Sorted Array
88. Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectivel...原创 2020-04-14 09:38:42 · 124 阅读 · 0 评论 -
【Leetcode】128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4, 200, 1, 3, 2]Output: 4Explan...原创 2020-04-14 09:38:03 · 130 阅读 · 0 评论 -
【LeetCode】849. Maximize Distance to Closest Person
【LeetCode】849. Maximize Distance to Closest Person849. Maximize Distance to Closest PersonEasyIn a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty....原创 2020-04-14 09:37:30 · 215 阅读 · 0 评论 -
344. Reverse String
344. Reverse StringEasyWrite a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by **modif...原创 2020-01-05 13:57:09 · 196 阅读 · 0 评论 -
541. Reverse String II
541. Reverse String IIEasyGiven a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characte...原创 2020-01-05 12:01:22 · 150 阅读 · 0 评论 -
557. Reverse Words in a String III
557. Reverse Words in a String IIIEasyGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:...原创 2020-01-05 10:50:14 · 214 阅读 · 0 评论 -
657. Robot Return to Origin
657. Robot Return to OriginEasyThere is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its mo...原创 2020-01-05 10:16:45 · 194 阅读 · 0 评论 -
1221. Split a String in Balanced Strings
1221. Split a String in Balanced StringsEasyBalanced strings are those who have equal quantity of ‘L’ and ‘R’ characters.Given a balanced string s split it in the maximum amount of balanced strings...原创 2020-01-04 19:09:28 · 195 阅读 · 0 评论 -
686. Repeated String Match
686. Repeated String MatchEasyGiven two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.For example, with A =...原创 2020-01-02 22:13:35 · 172 阅读 · 0 评论 -
459. Repeated Substring Pattern
459. Repeated Substring PatternEasyGiven a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the giv...原创 2020-01-01 19:16:35 · 193 阅读 · 0 评论 -
1108. Defanging an IP Address
1108. Defanging an IP AddressEasy183503ShareGiven a valid (IPv4) IP address, return a defanged version of that IP address.A defanged IP address replaces every period "." with "[.]".Example 1:Inp...原创 2020-01-01 18:16:19 · 165 阅读 · 0 评论 -
5. Longest Palindromic Substring
5. Longest Palindromic SubstringMediumGiven 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...原创 2019-11-20 18:52:26 · 172 阅读 · 0 评论