- 博客(156)
- 收藏
- 关注
原创 153_leetcode_Find Minimum in Rotated Sorted Array II
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.The array may contain duplicates.1
2014-10-25 10:54:46 386
原创 152_leetcode_Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in
2014-10-25 10:52:19 391
原创 151_leetcode_Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges
2014-10-25 10:45:35 396
原创 150_leetcode_Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo
2014-07-25 10:47:21 442
原创 149_leetcode_Text Justification
vector fullJustify(vector &words, int L) { vector result; if(words.size() == 0) { return result; } int wordLength = 0;
2014-07-25 09:25:44 357
原创 148_leetcode_Word Ladder II
vector > findLadders(string start, string end, unordered_set &dict) { vector > result; if(start.length() == 0 || end.length() == 0 || start.length() != end.length() || start == end
2014-07-24 13:30:35 447
原创 147_leetcode_Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Retu
2014-07-24 09:33:01 455
原创 146_leetcode_Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each
2014-07-23 17:25:06 322
原创 145_leetcode_Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"1:注意特殊情况;2:在u ni
2014-07-23 16:09:36 319
原创 144_leetcode_Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an
2014-07-23 11:06:36 305
原创 143_leetcode_Minimum Window Substring
string minWindow(string S, string T) { if(S.length() == 0 || T.length() == 0 || S.length() < T.length()) { return ""; } string result = "";
2014-07-23 09:47:59 498
原创 142_leetcode_Integer to Roman
string intToRoman(int num) { if(num <= 0) { return ""; } string result = ""; int tmpArray[13] = {1000, 900, 500, 400, 100, 90,
2014-07-22 17:01:22 357
原创 141_leetcode_Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.1:罗马数字 int romanToInt(string s) { if(s.size() == 0) {
2014-07-22 16:39:59 312
原创 140_leetcode_Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st
2014-07-22 16:18:23 353
原创 139_leetcode_Anagrams
vector anagrams(vector &strs) { if(strs.size() == 0) { return strs; } vector result; unordered_map myMap; for(int i = 0; i < (i
2014-07-22 15:30:34 347
原创 138_leetcode_Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m
2014-07-22 14:23:34 372
原创 137_leetcode_Implement strStr()
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.1:注意te shu q
2014-07-22 11:04:55 370
原创 136_leetcode_Jump Game II
int jump(int A[], int n) { if(A == NULL || n <= 1) { return 0; } int steps = 1; int curMaxIndex = A[0]; int index = 1;
2014-07-22 10:17:00 513
原创 134_leetcode_LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2014-07-22 09:43:17 375
原创 133_leetcode_Median of Two Sorted Array
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
2014-07-21 17:24:56 417
原创 131_leetcode_Valid Sudoku
bool isValidSudoku(vector > &board) { if(board.size() != 9 || board[0].size() != 9) { return false; } int rows = (int)board.size(); int
2014-07-21 16:25:28 405
原创 130_N-Queens II
计算N皇后的个数1:注意特殊情况;2:采用递归和回朔的 int totalNQueens(int n) { if( n <= 0 ) { return 0; } vector pos(n, 0); int totalNumber = 0;
2014-07-21 15:55:22 328
原创 129_leetcode_N-Queens
vector > solveNQueens(int n) { vector > result; if( n <= 0 ) { return result; } vector tmpSolve; vector pos(n, 0);
2014-07-21 15:48:04 348
原创 128_leetcode_Sort Colors
void sortColors(int A[], int n) { if(A == NULL || n <= 1) { return; } int leftIndex = -1; int rightIndex = n; int i = 0;
2014-07-21 15:18:42 400
原创 127_leetcode_Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non
2014-07-21 15:04:14 333
原创 126_leetcode_Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically
2014-07-21 14:44:00 405
原创 125_leetcode_Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.1:注意特殊情况, 点的个数为1,2, 0的shi hou
2014-07-21 14:17:46 237
原创 124_leetcode_Surrounded Regions
void solve(vector> &board) { if(board.size() == 0 || board.size() == 1 || board[0].size() == 1 || board.size() == 2 || board[0].size() == 2) return; int rows = (in
2014-07-21 13:58:14 347
原创 123_leetcode_Word Break II
vector wordBreak(string s, unordered_set &dict) { vector result; if(s.length() < 1 || dict.size() == 0) { return result; } unordered_se
2014-07-21 13:30:09 461
原创 122_leetcode_wordBreak
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"
2014-07-21 11:13:27 376
原创 121_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
2014-06-30 08:18:40 297
原创 120_leetcode_Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire
2014-06-30 08:02:30 331
原创 119_leetcode_Permutations 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].
2014-06-30 07:41:58 411
原创 118_leetcode_Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"],
2014-06-25 09:51:51 313
原创 117_leetcode_Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2014-06-25 09:37:08 349
原创 116_leetcode_Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.1:特殊情况;2:设置数组,字符串xiang che str
2014-06-24 16:59:38 298
原创 115_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""231""3
2014-06-24 16:00:15 309
原创 114_leetcode_Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2014-06-24 15:26:41 439
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人