![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Cycle1413
这个作者很懒,什么都没留下…
展开
-
LeetCode 011: Container With Most Water
011. Container With Most WaterDifficulty: Medium 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 endpoin原创 2016-05-11 10:04:21 · 254 阅读 · 0 评论 -
LeetCode 214: Shortest Palindrome
214. Shortest PalindromeDifficulty: Hard Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by pe原创 2016-06-30 14:46:28 · 556 阅读 · 0 评论 -
LeetCode 330: Patching Array
330. Patching ArrayDifficulty: Hard Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum原创 2016-07-01 14:40:58 · 321 阅读 · 0 评论 -
LeetCode 318: Maximum Product of Word Lengths
318. Maximum Product of Word LengthsDifficulty: Medium Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters.You may a原创 2016-06-16 15:22:34 · 304 阅读 · 0 评论 -
LeetCode 274: H-Index
274. H-IndexDifficulty: Medium Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition原创 2016-06-07 19:20:40 · 344 阅读 · 0 评论 -
LeetCode 275: H-Index II
275. H-Index IIDifficulty: Medium Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?Hint: Expected runtime complexity is in O(log n) a原创 2016-06-16 16:05:27 · 362 阅读 · 0 评论 -
LeetCode 263: Ugly Number
263. Ugly NumberDifficulty: Easy Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugl原创 2016-06-16 16:15:25 · 724 阅读 · 0 评论 -
LeetCode 264: Ugly Number II
264. Ugly Number IIDifficulty: Medium Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10,原创 2016-06-16 16:38:25 · 344 阅读 · 0 评论 -
LeetCode 368: Largest Divisible Subset
368. Largest Divisible SubsetDifficulty: Medium Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj原创 2016-07-15 14:46:18 · 445 阅读 · 1 评论 -
LeetCode 374: Guess Number Higher or Lower
374. Guess Number Higher or LowerDifficulty: Easy 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 wr原创 2016-07-15 14:55:09 · 326 阅读 · 0 评论 -
LeetCode 239: Sliding Window Maximum
239. Sliding Window MaximumDifficulty: Hard Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers i原创 2016-07-06 15:09:53 · 311 阅读 · 0 评论 -
LeetCode 209: Minimum Size Subarray Sum
209. Minimum Size Subarray SumDifficulty: Medium Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return原创 2016-07-07 15:40:30 · 379 阅读 · 0 评论 -
LeetCode 092: Reverse Linked List II
092. Reverse Linked List IIDifficulty: Medium Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->原创 2016-06-22 10:21:25 · 316 阅读 · 0 评论 -
LeetCode 206: Reverse Linked List
206. Reverse Linked ListDifficulty: Easy Reverse a singly linked list.思路为了反转链表,需要改变链表中指针的方向,使next指向前面一个结点。 每次调整一个结点,已调整的结点的下一结点为前面的结点。 假设需要调整结点i,调整结束后,i的next要指向它前面的结点h,且链表会在i和最初next指向的结点j之间断裂,为了防止无法原创 2016-06-22 09:33:34 · 298 阅读 · 0 评论 -
LeetCode 141: Linked List Cycle
141. Linked List CycleDifficulty: Easy Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?思路定义两个指针,同时从链表头结点出发,一个指针一次走一步,另一个指针一次走两步。如果快的指针追上了慢原创 2016-06-22 10:28:32 · 259 阅读 · 0 评论 -
LeetCode 268: Missing Number
268. Missing NumberDifficulty: Medium Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2原创 2016-06-03 14:24:22 · 273 阅读 · 0 评论 -
LeetCode 228: Summary Ranges
228. Summary RangesDifficulty: Medium Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].思路由于数组元素已排好序,而且没有原创 2016-06-03 14:02:16 · 329 阅读 · 0 评论 -
LeetCode 007: Reverse Integer
Reverse Integer Difficulty: Easy Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some g原创 2016-05-11 09:18:20 · 323 阅读 · 0 评论 -
LeetCode 012: Integer to Roman
012. Integer to RomanDifficulty: Medium Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.思路首先要知道罗马数字的记数方法,罗马数字采用七个罗马字母作数字: 基本字符 I V X原创 2016-05-11 10:46:31 · 287 阅读 · 0 评论 -
LeetCode 328: Odd Even Linked List
328. Odd Even Linked ListDifficulty: Medium Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value原创 2016-05-25 15:14:32 · 424 阅读 · 0 评论 -
LeetCode 345: Reverse Vowels of a String
345. Reverse Vowels of a StringDifficulty: Easy Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = “hello”, return “holle”. Example 2: Give原创 2016-05-25 16:04:38 · 427 阅读 · 0 评论 -
LeetCode 329: Longest Increasing Path in a Matrix
329. Longest Increasing Path in a MatrixDifficulty: Hard Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right,原创 2016-05-25 15:36:44 · 389 阅读 · 0 评论 -
LeetCode 219: Contains Duplicate II
219. Contains Duplicate IIDifficulty: Easy Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the differe原创 2016-05-05 10:30:21 · 276 阅读 · 0 评论 -
LeetCode 217: Contains Duplicate
217.Contains DuplicateDifficulty: Easy Given an array of integers, find if thearray contains any duplicates. Your function should return true if any valueappears at least twice in the array, and it sh原创 2016-05-05 10:36:02 · 313 阅读 · 0 评论 -
LeetCode 003: Longest Substring Without Repeating Characters
004. Longest Substring Without Repeating CharactersDifficulty: Medium Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer原创 2016-05-05 16:43:00 · 399 阅读 · 0 评论 -
LeetCode 136: Single Number
136. Single NumberDifficulty: Medium Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could原创 2016-05-05 17:34:21 · 244 阅读 · 0 评论 -
LeetCode 005: Longest Palindromic Substring
005. Longest Palindromic Substring思路回文可分为两种情况:AA’和AbA’(A为字符串,A’为A的反转字符串,b为一个字符)。 对于字符串s的每个字符,分别计算把它当作A的末尾字符和b时可取得的最长回文。 使用string的substr方法获取该回文子串。代码[C++]class Solution {public: string longestPali原创 2016-05-19 09:41:03 · 295 阅读 · 0 评论 -
LeetCode 020: Valid Parentheses
020. Valid ParenthesesDifficulty: Easy Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct or原创 2016-05-19 10:01:02 · 304 阅读 · 0 评论 -
LeetCode 035: Search Insert Position
035. Search Insert PositionDifficulty: Medium Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order原创 2016-05-19 10:14:23 · 253 阅读 · 0 评论 -
LeetCode 316: Remove Duplicate Letters
316. Remove Duplicate LettersDifficulty: Hard Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your re原创 2016-06-07 19:36:01 · 336 阅读 · 0 评论 -
LeetCode 091: Decode Ways
091. Decode WaysDifficulty: Medium A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing原创 2016-06-03 13:48:57 · 262 阅读 · 0 评论 -
LeetCode 142: Linked List Cycle II
142. Linked List Cycle IIDifficulty: Medium Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve原创 2016-06-22 10:48:38 · 311 阅读 · 0 评论