leecode
文章平均质量分 50
爱你多过爱自己
我很好。
展开
-
Leetcode [Palindrome Number]
Problem:Palindrome NumberQuestion:Determine whether an integer is a palindrome. Do this without extra space.思路题目要求在不使用多余空间的情况下判断一个整数是否是回文的(意即正着数和倒着数是一样的)。 直接用一个循环,每次取最高位和最低位比较,如果不相等就不用向下判断了,如果相等就继续判断,原创 2017-09-24 19:27:47 · 143 阅读 · 0 评论 -
LeetCode [70. Climbing Stairs]
Problem:70. Climbing StairsQuestionYou 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?No原创 2017-11-05 15:41:59 · 152 阅读 · 0 评论 -
LeetCode [11. Container With Most Water]
Problem11. Container With Most WaterQuestionGiven 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 l原创 2017-12-08 22:23:42 · 122 阅读 · 0 评论 -
LeetCode [10. Regular Expression Matching]
Problem10. Regular Expression MatchingQuestionImplement regular expression matching with support for ‘.’ and ‘*’.'.' Matches any single character.'*' Matches zero or more of the preceding element.The原创 2017-12-09 21:22:10 · 135 阅读 · 0 评论 -
LeetCode [Median of Two Sorted Arrays]
Problem:4. Median of Two Sorted ArraysQuestionThere 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 b原创 2017-11-26 14:48:08 · 254 阅读 · 1 评论 -
LeetCode [6. ZigZag Conversion]
Problem: 6. ZigZag ConversionQuestion: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 l原创 2017-11-26 15:23:53 · 139 阅读 · 0 评论 -
18. 4Sum
Problem18. 4SumQuestionGiven 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.No原创 2017-12-23 10:46:22 · 142 阅读 · 0 评论 -
16. 3Sum Closest
Problem16. 3Sum ClosestQuestionGiven an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that原创 2017-12-23 10:51:43 · 135 阅读 · 0 评论 -
19. Remove Nth Node From End of List
Problem19. Remove Nth Node From End of ListQuestionGiven a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After原创 2017-12-23 10:54:15 · 204 阅读 · 0 评论 -
算法期中 最小和
Problem从数列A[0], A[1], A[2], …, A[N-1]中选若干个数,要求对于每个i(0<=i < N-1),A[i]和A[i+1]至少选一个数,求能选出的最小和.1 <= N <= 100000, 1 <= A[i] <= 1000请为下面的Solution类实现解决上述问题的函数minSum,函数参数A是给出的数列,返回值为所求的最小和.例1:A = {2, 5, 2},答案为原创 2017-12-07 09:21:39 · 467 阅读 · 0 评论 -
LeetCode [12. Integer to Roman]
Problem12. Integer to RomanQuestionGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路罗马数字的详细介绍请点击这里罗马数字思路比较简单,把数字拆解为千百十个位,每个位都对应一个罗马表示,最后把所有罗马表原创 2017-12-08 08:11:29 · 114 阅读 · 0 评论 -
15. 3Sum
Problem15. 3SumQuestionGiven 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 solution set原创 2017-12-17 20:47:00 · 136 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
Problem17. Letter Combinations of a Phone NumberQuestionGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the tel原创 2017-12-17 20:48:50 · 131 阅读 · 0 评论 -
LeetCode [53. Maximum Subarray]
Problem:53. Maximum SubarrayQuestionFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the co原创 2017-11-05 15:37:45 · 127 阅读 · 0 评论 -
LeetCode [303. Range Sum Query - Immutable]
Problem:303. Range Sum Query - ImmutableQuestionGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0原创 2017-11-05 15:28:08 · 132 阅读 · 0 评论 -
Leetcode [210. Course Schedule II]
Problem:210. Course Schedule IIQuestionThere 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原创 2017-11-05 14:50:30 · 153 阅读 · 0 评论 -
Leetcode [Roman to Integer]
Problem:Roman to IntegerQuestionGiven a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.思路 罗马数字共有7个,即Ⅰ(1)、Ⅴ(5)、Ⅹ(10)、Ⅼ(50)、Ⅽ(100)、Ⅾ(500)和Ⅿ(1000)。按照原创 2017-09-24 19:41:05 · 199 阅读 · 0 评论 -
Leetcode [Longest Common Prefix]
Problem:Longest Common PrefixQuestionWrite a function to find the longest common prefix string amongst an array of strings.思路寻找一连串字符串的最长共同前缀。 我第一想法是,首先假定第一个字符串就是最大前缀(如果这个数组为空那这个字符串就是空)。依次向后调整这个前缀。有以下几原创 2017-09-24 19:47:14 · 188 阅读 · 0 评论 -
Leetcode [Longest Substring Without Repeating Characters]
Problem:Longest Substring Without Repeating CharactersQuesitonGiven a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”,原创 2017-09-16 15:21:37 · 149 阅读 · 0 评论 -
Leetcode [Reverse Integer]
Problem:Reverse IntegerQuestionReverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integer. Your function s原创 2017-09-16 15:25:37 · 170 阅读 · 0 评论 -
Leetcode [Add Two Numbers]
Problem:Add Two NumbersQuestionYou 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. A原创 2017-09-11 13:29:29 · 213 阅读 · 0 评论 -
Leetcode [Valid Parentheses]
Problem : Valid ParenthesesQuestionGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order,原创 2017-10-10 16:57:31 · 177 阅读 · 1 评论 -
Leetcode [Merge Two Sorted Lists]
Merge Two Sorted Lists原创 2017-10-10 17:01:23 · 161 阅读 · 0 评论 -
Leetcode [8. String to Integer (atoi)]
Problem:8. String to Integer (atoi)QuestionImplement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask y原创 2017-10-28 21:57:41 · 370 阅读 · 0 评论 -
Leetcode [300. Longest Increasing Subsequence]
Problem:300. Longest Increasing SubsequenceQuestionGiven 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原创 2017-10-28 22:20:44 · 138 阅读 · 0 评论 -
Leetcode [Longest Palindromic Substring]
Problem:Longest Palindromic SubstringQuestionGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.思路Manacher算法对于一个字符串,除了直接遍历以外,也可以用扩展的方式来找字原创 2017-10-10 17:54:38 · 193 阅读 · 0 评论 -
Leetcode [609. Find Duplicate File in System]
Problem:609. Find Duplicate File in SystemQuestionGiven a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of dupl原创 2017-10-21 18:23:30 · 180 阅读 · 0 评论 -
Leetcode [207. Course Schedule]
Problem:207. Course ScheduleQuestionThere 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 cou原创 2017-10-21 17:24:01 · 177 阅读 · 0 评论 -
22. Generate Parentheses
Problem:22. Generate ParenthesesDescriptionGiven 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-12-31 21:21:14 · 145 阅读 · 0 评论