![](https://img-blog.csdnimg.cn/20190927151026427.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
文章平均质量分 68
LeetCode题解记录
Richard_Che
这个作者很懒,什么都没留下…
展开
-
LeetCode题解(Week2):179. Largest Number
原题目Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be v原创 2017-02-28 23:32:03 · 363 阅读 · 0 评论 -
Leetcode题解(Week 7):322. Coin Change
原题目You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of mone原创 2017-04-15 22:32:45 · 294 阅读 · 0 评论 -
LeetCode 题解(Week 11):Word Break
原题目:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may a原创 2017-05-14 08:57:58 · 282 阅读 · 0 评论 -
LeetCode 题解(Week 10): 467. Unique Substrings in Wraparound String
原题目Consider the string s to be the infinite wraparound string of “abcdefghijklmnopqrstuvwxyz”, so s will look like this: “…zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv xyzabcd….”.Now we have anoth原创 2017-05-08 23:01:00 · 335 阅读 · 0 评论 -
LeetCode 题解(Week 12):375. Guess Number Higher or Lower II
原题目:We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number I picked is h原创 2017-05-18 09:46:20 · 272 阅读 · 0 评论 -
LeetCode题解(Week 13):128. Longest Consecutive Sequence
原题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3,原创 2017-06-01 08:42:23 · 210 阅读 · 0 评论 -
LeetCode 题解(Week 14):468. Validate IP Address
原题目Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decima原创 2017-06-05 15:57:55 · 347 阅读 · 0 评论 -
LeetCode题解(Week 16):3. Longest Substring Without Repeating Characters
原题目:Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “原创 2017-06-16 14:39:05 · 315 阅读 · 0 评论 -
LeetCode题解(Week 4):491. Increasing Subsequences
原题目Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .Example: Input原创 2017-03-19 12:45:12 · 482 阅读 · 0 评论 -
LeetCode题解(Week5): 515. Find Largest Value in Each Tree Row
原题目You need to find the largest value in each row of a binary tree.Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]中文大意找出一棵树中每一层的最大值题解/** * Definition for原创 2017-03-26 11:49:33 · 306 阅读 · 0 评论 -
LeetCode题解(Week 8):403. Frog Jump
原题目A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list of s原创 2017-04-19 10:45:32 · 441 阅读 · 0 评论 -
LeetCode 题解(Week15):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: [ “((()))”, “(()())”, “(())()”, “()(原创 2017-06-11 12:15:38 · 384 阅读 · 0 评论 -
LeetCode 题解(Week6):300. Longest Increasing Subsequence
原题目Given an unsorted array of integers, find the length of longest increasing subsequence.For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], theref原创 2017-04-06 10:11:07 · 293 阅读 · 0 评论 -
LeetCode题解(Week 9):486. Predict the Winner
原题目:Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player pick原创 2017-04-29 23:38:35 · 277 阅读 · 0 评论 -
LeetCode 题解(Week 8): 523. Continuous Subarray Sum
原题目:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up原创 2017-04-17 23:18:01 · 395 阅读 · 0 评论 -
LeetCode题解(Week 1):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原创 2017-02-26 10:22:36 · 262 阅读 · 0 评论 -
LeetCode题解(Week 1):287. Find the Duplicate Number
题目:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,原创 2017-02-25 00:41:24 · 287 阅读 · 0 评论 -
LeetCode题解(Week 1):414. Third Maximum Number
LeetCode题解(Week 1):414. Third Maximum Number原题目:Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity原创 2017-02-22 19:15:55 · 466 阅读 · 0 评论 -
LeetCode题解(Week2):148. Sort List
原题目Sort a linked list in O(n log n) time using constant space complexity.中文大意对一个链表进行排序,要求算法的时间复杂度是O(n log n),空间复杂度是常数题解/** * Definition for singly-linked list. * struct ListNode { *原创 2017-03-05 11:40:28 · 212 阅读 · 0 评论 -
LeetCode题解(Week2):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.中文大意对两个有序的链表进行合并,返回一个新的链表。这个新的链表应该是能够通过旧链表节点的重新连接而产生的。题解/原创 2017-03-05 11:33:52 · 258 阅读 · 0 评论 -
LeetCode题解(Week 3):206. Reverse Linked List
原题目Reverse a singly linked list.中文大意实现链表的逆置,通过两种方式(递归和迭代)来实现题解1:迭代方式class Solution {public: ListNode* reverseList(ListNode* head) { //题目的输入中存在空链表,先对这种特殊情况进行处理 if(head==NULL) r原创 2017-03-11 10:57:45 · 244 阅读 · 0 评论 -
LeetCode题解(Week 3):445. Add Two Numbers II
原题目 You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers a原创 2017-03-11 11:26:17 · 242 阅读 · 0 评论 -
LeetCode 题解(Week 5):502. IPO
原题目Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since i原创 2017-03-31 11:37:56 · 412 阅读 · 0 评论 -
LeetCode题解(Week 5) 452. Minimum Number of Arrows to Burst Balloons
原题目There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it’s horizontal, y-coord原创 2017-04-01 20:47:26 · 541 阅读 · 0 评论 -
LeetCode题解(Week5):207. Course Schedule
原题目There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pa原创 2017-03-26 12:13:37 · 325 阅读 · 0 评论