摘要: Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.The input string does not contain lead... 阅读全文
posted @ 2015-02-10 16:25 Vae永Silence 阅读(268) 评论(0) 推荐(0)
摘要: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up... 阅读全文
posted @ 2015-02-10 14:38 Vae永Silence 阅读(146) 评论(0) 推荐(0)
摘要: Design and implement a TwoSum class. It should support the following operations:addandfind.add- Add the number to an internal data structure.find- Fin... 阅读全文
posted @ 2015-02-10 14:06 Vae永Silence 阅读(260) 评论(0) 推荐(0)
摘要: Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function t... 阅读全文
posted @ 2015-02-10 14:03 Vae永Silence 阅读(142) 评论(0) 推荐(0)
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-02-10 14:00 Vae永Silence 阅读(121) 评论(0) 推荐(0)
摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
posted @ 2015-02-10 13:59 Vae永Silence 阅读(139) 评论(0) 推荐(0)
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2015-02-10 13:58 Vae永Silence 阅读(120) 评论(0) 推荐(0)
摘要: 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 ... 阅读全文
posted @ 2015-02-10 13:57 Vae永Silence 阅读(149) 评论(0) 推荐(0)
摘要: Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文
posted @ 2015-02-10 13:55 Vae永Silence 阅读(126) 评论(0) 推荐(0)
摘要: The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
posted @ 2015-02-10 13:54 Vae永Silence 阅读(161) 评论(0) 推荐(0)
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are som... 阅读全文
posted @ 2015-02-10 13:53 Vae永Silence 阅读(131) 评论(0) 推荐(0)
摘要: Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文
posted @ 2015-02-10 13:51 Vae永Silence 阅读(146) 评论(0) 推荐(0)
摘要: Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i... 阅读全文
posted @ 2015-02-10 13:50 Vae永Silence 阅读(151) 评论(0) 推荐(0)
摘要: Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2015-02-10 13:49 Vae永Silence 阅读(135) 评论(0) 推荐(0)
摘要: Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2015-02-10 13:48 Vae永Silence 阅读(111) 评论(0) 推荐(0)
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.public class Solution { public String int... 阅读全文
posted @ 2015-02-10 13:46 Vae永Silence 阅读(122) 评论(0) 推荐(0)
摘要: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int romanToInt(st... 阅读全文
posted @ 2015-02-10 13:45 Vae永Silence 阅读(108) 评论(0) 推荐(0)
摘要: Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector &st... 阅读全文
posted @ 2015-02-10 13:44 Vae永Silence 阅读(164) 评论(0) 推荐(0)
摘要: Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2015-02-10 13:43 Vae永Silence 阅读(131) 评论(0) 推荐(0)
摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2015-02-10 13:41 Vae永Silence 阅读(132) 评论(0) 推荐(0)
摘要: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文
posted @ 2015-02-10 13:40 Vae永Silence 阅读(207) 评论(0) 推荐(0)
摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2015-02-10 13:39 Vae永Silence 阅读(149) 评论(0) 推荐(0)
摘要: Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2015-02-10 13:38 Vae永Silence 阅读(148) 评论(0) 推荐(0)
摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2015-02-10 13:36 Vae永Silence 阅读(153) 评论(0) 推荐(0)
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def... 阅读全文
posted @ 2015-02-10 13:35 Vae永Silence 阅读(113) 评论(0) 推荐(0)
摘要: Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文
posted @ 2015-02-10 13:34 Vae永Silence 阅读(119) 评论(0) 推荐(0)
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity./** * Definition for singly-linked list. * struct List... 阅读全文
posted @ 2015-02-10 13:32 Vae永Silence 阅读(118) 评论(0) 推荐(0)
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2015-02-10 13:31 Vae永Silence 阅读(125) 评论(0) 推荐(0)
摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2015-02-10 13:30 Vae永Silence 阅读(126) 评论(0) 推荐(0)
摘要: Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2015-02-10 13:28 Vae永Silence 阅读(97) 评论(0) 推荐(0)
摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2015-02-10 13:27 Vae永Silence 阅读(129) 评论(0) 推荐(0)
摘要: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The si... 阅读全文
posted @ 2015-02-10 13:23 Vae永Silence 阅读(123) 评论(0) 推荐(0)
摘要: Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.class Solution {public: int divide(in... 阅读全文
posted @ 2015-02-10 13:20 Vae永Silence 阅读(133) 评论(0) 推荐(0)
摘要: 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 concatenati... 阅读全文
posted @ 2015-02-10 13:18 Vae永Silence 阅读(133) 评论(0) 推荐(0)
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2015-02-10 13:16 Vae永Silence 阅读(182) 评论(0) 推荐(0)
摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2015-02-10 13:14 Vae永Silence 阅读(113) 评论(0) 推荐(0)
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2015-02-10 13:13 Vae永Silence 阅读(133) 评论(0) 推荐(0)
摘要: Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2015-02-10 13:11 Vae永Silence 阅读(110) 评论(0) 推荐(0)
摘要: 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 or... 阅读全文
posted @ 2015-02-10 13:10 Vae永Silence 阅读(177) 评论(0) 推荐(0)
摘要: Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with ... 阅读全文
posted @ 2015-02-10 13:09 Vae永Silence 阅读(150) 评论(0) 推荐(0)
摘要: 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 on... 阅读全文
posted @ 2015-02-10 13:07 Vae永Silence 阅读(136) 评论(0) 推荐(0)
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文
posted @ 2015-02-10 13:06 Vae永Silence 阅读(119) 评论(0) 推荐(0)
摘要: Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文
posted @ 2015-02-10 13:05 Vae永Silence 阅读(195) 评论(0) 推荐(0)
摘要: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number ... 阅读全文
posted @ 2015-02-10 13:03 Vae永Silence 阅读(185) 评论(0) 推荐(0)
摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文
posted @ 2015-02-10 13:01 Vae永Silence 阅读(134) 评论(0) 推荐(0)
摘要: Givennnon-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.Fo... 阅读全文
posted @ 2015-02-10 13:00 Vae永Silence 阅读(150) 评论(0) 推荐(0)
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2015-02-10 12:58 Vae永Silence 阅读(137) 评论(0) 推荐(0)
摘要: Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e... 阅读全文
posted @ 2015-02-10 12:57 Vae永Silence 阅读(147) 评论(0) 推荐(0)
摘要: 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 maximu... 阅读全文
posted @ 2015-02-10 12:56 Vae永Silence 阅读(119) 评论(0) 推荐(0)
摘要: 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,... 阅读全文
posted @ 2015-02-10 12:55 Vae永Silence 阅读(115) 评论(0) 推荐(0)
摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm... 阅读全文
posted @ 2015-02-10 12:54 Vae永Silence 阅读(157) 评论(0) 推荐(0)
摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?class Solution {pub... 阅读全文
posted @ 2015-02-10 12:52 Vae永Silence 阅读(109) 评论(0) 推荐(0)
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.class Solution {public:string tostrin... 阅读全文
posted @ 2015-02-10 12:51 Vae永Silence 阅读(192) 评论(0) 推荐(0)
摘要: Implement pow(x,n).class Solution {public: double pow(double x, int n) { if(n==0)return 1.0; if(n0) { double half=p... 阅读全文
posted @ 2015-02-10 12:42 Vae永Silence 阅读(133) 评论(0) 推荐(0)
摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2015-02-10 12:41 Vae永Silence 阅读(149) 评论(0) 推荐(0)
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.class Solution {public:void... 阅读全文
posted @ 2015-02-10 12:39 Vae永Silence 阅读(135) 评论(0) 推荐(0)
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-02-10 12:37 Vae永Silence 阅读(150) 评论(0) 推荐(0)