- 博客(290)
- 资源 (1)
- 收藏
- 关注
原创 99. Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you dev
2016-08-11 14:28:06
324
原创 97. Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", r
2016-08-11 14:26:50
359
原创 leetcode.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 pi
2016-07-21 15:53:01
487
原创 leetcode.374. Guess Number Higher or Lower
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 is h
2016-07-21 15:09:21
265
原创 leetcode.184. Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.+----+-------+--------+--------------+| Id | Name | Salary | Departme
2016-07-11 21:21:50
995
原创 leetcode.177. Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exampl
2016-07-11 14:21:57
451
原创 leetcode.197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.+---------+------------+------------------+| Id(INT) | Date(DA
2016-07-11 12:18:16
326
原创 leetcode.196. Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+------------------+| Id | Email |+----+-----
2016-07-11 12:05:32
270
原创 leetcode.183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.+----+-------+| Id | Na
2016-07-11 11:44:40
252
原创 leetcode.182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For
2016-07-11 11:22:41
324
原创 leetcode.181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary |
2016-07-11 11:11:32
248
原创 leetcode.176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exa
2016-07-11 10:37:17
261
原创 leetcode.175. Combine Two Tables
Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Per
2016-07-11 09:52:34
276
原创 leetcode.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 the matrix such that its sum is no larger than k.Example:Given matrix = [ [1, 0, 1], [0, -2, 3]]k
2016-07-10 23:13:12
402
原创 leetcode.368. Largest Divisible Subset
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% Si = 0.If there are multiple solutions
2016-07-10 16:59:07
209
原创 leetcode.373. Find K Pairs with Smallest Sums
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the first array and one element from the second a
2016-07-09 22:27:29
293
原创 leetcode.372. Super Pow
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1:a = 2b = [3]Result: 8Example
2016-07-09 18:03:29
1224
原创 leetcode.367. Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16Return
2016-07-06 17:50:12
200
原创 leetcode.371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.class Solution {public: int getSum(int a, int b)
2016-07-06 17:36:54
215
原创 leetcode.354. Russian Doll Envelopes
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than
2016-06-25 20:25:23
197
原创 leetcode.355. Design Twitter
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the fo
2016-06-24 19:00:02
309
原创 leetcode.365. Water and Jug Problem
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly zlitres using these two
2016-06-24 16:30:51
524
原创 leetcode.357. Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x [11,22,33,44,
2016-06-23 22:42:45
184
原创 leetcode.44. Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover
2016-06-03 22:46:48
214
原创 leetcode.352. Data Stream as Disjoint Intervals
Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.For example, suppose the integers from the data stream ar
2016-06-03 21:41:49
751
原创 求一个字符串中连续出现次数最多的子串
#include #include using namespace std;void main(){ string str = "abcabcabcccccdefefefefefef"; int len = str.length(); int maxCount = 0; string longest = ""; for(int pos1 = 0;
2016-06-02 14:51:46
185
原创 leetcode.312. Burst Balloons
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooni you will get nums[
2016-05-26 23:10:33
296
原创 leetcode.301. Remove Invalid Parentheses
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( and).
2016-05-26 22:41:33
1016
原创 leetcode.91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number
2016-05-26 21:53:02
190
原创 leetcode.273. Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousand Thre
2016-05-26 21:00:02
199
原创 leetcode.45. Jump Game II
Given 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 position.Your goal is
2016-05-26 17:32:15
184
原创 leetcode.37. Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution. A sudoku puzzle
2016-05-26 16:46:21
156
原创 leetcode.164. Maximum Gap
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements.Y
2016-05-26 15:02:25
237
原创 leetcode.336. Palindrome Pairs
Given a list of unique words. Find all pairs of distinct indices(i, j) in the given list, so that the concatenation of the two words, i.e.words[i] + words[j] is a palindrome.Example 1:Given wo
2016-05-26 14:22:16
254
原创 leetcode.56. Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. /** * Definition for an interval. * struct Inte
2016-05-25 17:49:23
209
原创 leetcode.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 "()", whic
2016-05-25 17:15:58
215
原创 leetcode.138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list. class Solution {public:
2016-05-25 16:52:30
243
原创 leetcode.87. Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr
2016-05-25 14:49:08
201
原创 leetcode.321. Create Maximum Number
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of lengthk from digits of the two. The relative order of the digits from the same array must b
2016-05-25 12:48:01
257
原创 leetcode.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
2016-05-24 22:38:29
210
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人