
LeetCode
文章平均质量分 74
leileicaocao
这个作者很懒,什么都没留下…
展开
-
LeetCode_ValidPalindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is no原创 2013-06-26 19:19:44 · 429 阅读 · 0 评论 -
LeetCode_Permute
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].void DFS(vect原创 2013-06-28 15:04:07 · 582 阅读 · 0 评论 -
LeetCode_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 t原创 2013-06-28 18:03:20 · 442 阅读 · 0 评论 -
LeetCode_Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100"class Solution {public: string addBinary(string a, string b) { // Start原创 2013-06-27 23:17:04 · 520 阅读 · 0 评论 -
LeetCode_Unique Path II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the原创 2013-06-27 23:45:50 · 514 阅读 · 0 评论 -
LeetCode_Permute II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1原创 2013-06-28 15:11:49 · 616 阅读 · 0 评论 -
LeetCode_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 i原创 2013-06-28 15:54:11 · 466 阅读 · 0 评论 -
LeetCode_Length Of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2013-06-28 10:20:15 · 505 阅读 · 0 评论 -
LeetCode_Can Jump
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.Determine i原创 2013-06-28 11:59:15 · 545 阅读 · 0 评论 -
LeetCode_Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,原创 2013-06-30 10:28:54 · 485 阅读 · 0 评论 -
LeetCode_Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the c原创 2013-06-30 12:22:33 · 491 阅读 · 0 评论 -
LeetCode_Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213"原创 2013-06-30 20:55:27 · 505 阅读 · 0 评论 -
LeetCode_Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited原创 2013-06-30 11:32:12 · 486 阅读 · 0 评论 -
LeetCode_Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.原创 2013-06-26 19:22:08 · 388 阅读 · 0 评论 -
LeetCode_Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach th原创 2013-06-27 23:33:55 · 442 阅读 · 0 评论 -
LeetCode_Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?class Solution {public: void rotate(vector >原创 2013-06-28 14:51:21 · 503 阅读 · 0 评论 -
LeetCode_Plus One
Given a number represented as an array of digits, plus one to the number.class Solution {public: vector plusOne(vector &arr) { // Start typing your C/C++ solution below // DO NO原创 2013-06-27 22:49:10 · 524 阅读 · 0 评论 -
LeetCode_Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain d原创 2013-06-26 21:11:50 · 425 阅读 · 0 评论 -
LeetCode_Restore IP Address
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Orde原创 2013-06-26 19:03:18 · 464 阅读 · 0 评论 -
LeetCode_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",原创 2013-06-26 19:11:32 · 398 阅读 · 0 评论 -
LeetCode_Reverse Linked List II
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->NULL.Note:Given m, n satisfy原创 2013-06-26 20:24:10 · 454 阅读 · 0 评论 -
LeetCode_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 nu原创 2013-06-26 22:18:52 · 437 阅读 · 0 评论 -
LeetCode Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1原创 2013-06-26 19:26:51 · 421 阅读 · 0 评论 -
LeetCode_Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4原创 2013-06-27 11:29:10 · 409 阅读 · 0 评论 -
LeetCode_Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of原创 2013-06-27 10:34:06 · 446 阅读 · 0 评论 -
LeetCode_Set Matrix Zeros
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.class Solution {public: void setZeroes(vector > &matrix) { // Start typing your C/C++ solu原创 2013-06-27 15:11:39 · 737 阅读 · 0 评论 -
Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you consider the case w原创 2013-06-27 17:35:09 · 488 阅读 · 0 评论 -
LeetCode_Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integer原创 2013-06-27 15:03:31 · 425 阅读 · 0 评论 -
LeetCode_Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a w原创 2013-06-27 16:21:49 · 454 阅读 · 0 评论 -
LeetCode_Sqrt
Implement int sqrt(int x).Compute and return the square root of x.class Solution {public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write i原创 2013-06-27 22:27:40 · 653 阅读 · 0 评论 -
LeetCode_FirstMissingPositive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses consta原创 2013-07-22 09:34:24 · 567 阅读 · 0 评论