![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
hzw2945
这个作者很懒,什么都没留下…
展开
-
Leetcode题解-5. Longest Palindromic Substring
5. Longest Palindromic SubstringGiven 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"N原创 2017-09-17 22:36:46 · 246 阅读 · 0 评论 -
Leetcode题解-23. Merge k Sorted Lists
Leetcode题解-23. Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.(链表元素从小到大排序)思路之前做过合并2个有序链表的题目,这题无非就是把合并两条链表后产生的新链表和剩下的链表中的一条进行合并,直到没原创 2017-10-16 15:56:37 · 169 阅读 · 0 评论 -
Leetcode题解-24. Swap Nodes in Pairs
Leetcode题解-24. Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should u原创 2017-10-16 19:26:35 · 206 阅读 · 0 评论 -
Leetcode题解-3Sum&3Sum Closest
Leetcode题解-3Sum&3Sum Closest3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solu原创 2017-11-12 22:30:42 · 227 阅读 · 0 评论 -
Leetcode题解-33. Search in Rotated Sorted Array
Leetcode题解-33. Search in Rotated Sorted ArraySuppose 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 given原创 2017-11-05 18:43:06 · 212 阅读 · 0 评论 -
Leetcode题解-48. Rotate Image
Leetcode题解-48. Rotate ImageYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note: You have to rotate the image in-place, which means you have to modify原创 2017-11-19 23:06:08 · 163 阅读 · 0 评论 -
Leetcode题解-38. Count and Say
Leetcode题解-38. Count and Say题目The count-and-say sequence is the sequence of integers with the first five terms as following:111211211111221 1 is read off as “one 1” or 11. 11 is read off as “two原创 2017-12-03 21:29:34 · 187 阅读 · 0 评论 -
Leetcode题解-39. Combination Sum
Leetcode题解-39. Combination SumGiven a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeate原创 2017-12-24 17:33:07 · 190 阅读 · 0 评论 -
Leetcode题解-25. Reverse Nodes in k-Group
Leetcode题解-25. Reverse Nodes in k-GroupGiven 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 o原创 2017-12-07 17:16:01 · 222 阅读 · 0 评论 -
Leetcode题解-30. Substring with Concatenation of All Words
Leetcode题解-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) in s that is原创 2017-12-17 10:11:25 · 282 阅读 · 0 评论 -
Leetcode题解-747. Min Cost Climbing Stairs
Leetcode题解-747. Min Cost Climbing StairsOn a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to f原创 2018-01-03 09:24:28 · 277 阅读 · 0 评论 -
Leetcode题解-198. House Robber
Leetcode题解-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原创 2018-01-03 13:52:38 · 250 阅读 · 0 评论 -
Leetcode题解-55. Jump Game
Leetcode题解-55. Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that posit原创 2018-01-13 14:55:30 · 269 阅读 · 0 评论 -
Leetcode题解-18. 4Sum
Leetcode题解-18. 4SumGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:原创 2017-10-16 13:18:00 · 191 阅读 · 0 评论 -
Leetcode题解-21. Merge Two Sorted Lists
Leetcode题解-21. Merge Two Sorted ListsMerge 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(把两个从小到大的序列链表合并成一个从小到大的链原创 2017-10-13 09:38:49 · 189 阅读 · 0 评论 -
Leetcode题解-3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", w原创 2017-09-10 23:08:20 · 187 阅读 · 0 评论 -
Leetcode题解-6. ZigZag Conversion
Leetcode题解-6. ZigZag ConversionThe 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原创 2017-09-19 17:57:45 · 339 阅读 · 0 评论 -
Leetcode题解-461. Hamming Distance
Leetcode题解-461. Hamming Distance【easy】The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hammin原创 2017-09-28 10:51:10 · 193 阅读 · 0 评论 -
Leetcode题解-7&9
Leetcode题解-7&9由于题目比较简单而且两道题思路比较接近,将两道题合起来写7. Reverse Integer【easy】Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321Note: The input is assumed to be a 32-bit s原创 2017-09-28 10:28:22 · 145 阅读 · 0 评论 -
Leetcode题解-657. Judge Route Circle
Leetcode题解-657. Judge Route CircleInitially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The原创 2017-09-28 13:02:31 · 206 阅读 · 0 评论 -
Leetcode题解-617. Merge Two Binary Trees
Leetcode题解-617. Merge Two Binary TreesGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need t原创 2017-09-29 08:36:36 · 228 阅读 · 0 评论 -
Leetcode题解-561. Array Partition I
Leetcode题解-561. Array Partition IGiven an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all原创 2017-09-29 09:40:53 · 188 阅读 · 0 评论 -
Leetcode题解-11. Container With Most Water
Leetcode题解-11. Container With Most WaterGiven 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原创 2017-09-30 13:44:46 · 193 阅读 · 0 评论 -
Leetcode题解-500. Keyboard Row
Leetcode题解-500. Keyboard RowGiven a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below.American keyboard Example 1:原创 2017-09-30 17:51:32 · 233 阅读 · 0 评论 -
Leetcode题解-14. Longest Common Prefix
Leetcode题解-14. Longest Common Prefix给出一个字符串数组,求出所有字符串最长的公共前缀思路 想法1:对每个字符串相同位置的字符进行比较,直到出现不同字符或者超过其中一个字符串长度结束比较 想法2:每次将前缀和一个字符串的比较,取前缀和该字符串的最长公共前缀,直到比较完所有字符串代码想法1的代码string longestCommonPrefix(vector<s原创 2017-10-11 10:13:05 · 167 阅读 · 0 评论 -
Leetcode题解-31. Next Permutation
Leetcode题解-31. Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange原创 2017-10-29 16:45:04 · 381 阅读 · 0 评论 -
Leetcode题解-17. Letter Combinations of a Phone Number
Leetcode题解-17. Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telepho原创 2017-10-12 16:02:33 · 201 阅读 · 0 评论 -
Leetcode题解-62. Unique Paths & 63. Unique Paths II
Leetcode题解-62. Unique Paths & 63. Unique Paths II62.Unique Paths 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原创 2018-01-13 15:21:08 · 200 阅读 · 0 评论