- 博客(33)
- 收藏
- 关注
原创 140. Word Break II
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. You may assume the dict
2017-02-26 14:27:39 678
原创 446. Arithmetic Slices II - Subsequence
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequen
2017-02-25 14:42:04 301
原创 214. Shortest Palindrome
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 performing this transformation.For exam
2017-02-24 12:01:33 196
原创 32. Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",
2017-02-24 09:05:48 165
原创 23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Subscribe to see which companies asked this question.要求将k个已排序的链表合并成一个排序的链表。用priority_queue实现
2017-02-22 11:30:41 173
原创 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-02-21 20:03:40 144
原创 239. Sliding Window Maximum
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 thek numbers in the window. Each time the sliding window
2017-02-19 13:51:46 196
原创 480. Sliding Window Median
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median i
2017-02-18 11:43:32 568
原创 76. Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".
2017-02-17 12:32:47 273
原创 282. Expression Add Operators
Given a string that contains only digits 0-9 and a target value, return all possibilities to addbinary operators (not unary) +, -, or * between the digits so they evaluate to the target value.Ex
2017-02-16 20:22:24 153
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: You may
2017-02-15 13:18:08 172
原创 295. Find Median from Data Stream
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median i
2017-02-15 13:09:44 311
原创 493. Reverse Pairs
Given an array nums, we call (i, j) an important reverse pair ifi and nums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:Input: [1,3,2,3,
2017-02-14 13:59:23 1547
原创 432. All O`one Data Structure
Implement a data structure supporting the following operations:Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be anon-empty string.Dec(Key)
2017-02-13 13:44:03 262
原创 329. Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o
2017-02-12 14:28:53 197
原创 496. Next Greater Element I
You are given two arrays (without duplicates) nums1 andnums2 where nums1’s elements are subset of nums2. Find all the next greater numbers fornums1's elements in the corresponding places of nums2.
2017-02-11 14:55:56 413
原创 483. Smallest Good Base
For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1.Now given a string representing n, you should return the smallest good base of n in string format.Example 1:
2017-02-11 14:14:44 857
原创 363. Max Sum of Rectangle No Larger Than K
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in thematrix such that its sum is no larger than k.Example:Given matrix = [ [1, 0, 1], [0, -2, 3]]k
2017-02-10 14:04:41 176
原创 460. LFU Cache
Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations:get and put.get(key) - Get the value (will always be positive) of the key
2017-02-09 15:21:33 273
原创 506. Relative Ranks
Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1:Inpu
2017-02-09 11:00:36 1664
原创 126. Word Ladder II
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWord to endWord, such that:Only one letter can be changed at a timeEa
2017-02-08 15:13:41 423
原创 127. Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWord to endWord, such that:Only one letter can be changed at a
2017-02-08 11:45:14 260
原创 500. Keyboard Row
Given 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. Example 1:Input: ["Hello", "Alaska", "Dad
2017-02-07 13:14:44 337
原创 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 it
2017-02-07 12:54:45 1315
原创 410. Split Array Largest Sum
Given an array which consists of non-negative integers and an integer m, you can split the array intom non-empty continuous subarrays. Write an algorithm to minimize the largest sum among thesem s
2017-02-06 21:16:01 272
原创 481. Magical String
A magical string S consists of only '1' and '2' and obeys the following rules:The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates t
2017-02-04 18:34:39 1193
原创 68. Text Justification
Given an array of words and a length L, format the text such that each line has exactlyL characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is
2017-02-04 15:59:47 201
原创 412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.
2017-02-03 14:46:56 130
原创 224. Basic Calculator
Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty
2017-02-03 14:31:35 158
原创 130. Surrounded Regions
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X
2017-02-03 13:17:36 225
原创 165. Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and cont
2017-02-02 21:31:10 110
原创 143. Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4
2017-02-01 13:56:04 105
原创 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-02-01 12:43:44 146
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人