上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.method 1: use PriorityQueue (simple)/** * Definition f... 阅读全文
posted @ 2014-02-10 09:55 Averill Zheng 阅读(138) 评论(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 @ 2014-02-10 04:47 Averill Zheng 阅读(134) 评论(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 @ 2014-02-10 04:45 Averill Zheng 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.public class Solution { public ArrayList anagrams(String[] strs) { ArrayList result = new ArrayList(); if(strs.length > 0){ HashMap > words = new HashMap>(); for(String... 阅读全文
posted @ 2014-02-09 12:44 Averill Zheng 阅读(122) 评论(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 @ 2014-02-08 09:56 Averill Zheng 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.public class Solution { public int minDepth(TreeNode root) { int depth = 0; if(root != null){ if(root.left == null) ... 阅读全文
posted @ 2014-02-03 08:40 Averill Zheng 阅读(135) 评论(0) 推荐(1) 编辑
摘要: 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 @ 2014-02-03 08:29 Averill Zheng 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ... 阅读全文
posted @ 2014-02-03 02:44 Averill Zheng 阅读(314) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 ... 阅读全文
posted @ 2014-02-03 02:17 Averill Zheng 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 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.... 阅读全文
posted @ 2014-02-02 11:44 Averill Zheng 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co... 阅读全文
posted @ 2014-02-02 11:20 Averill Zheng 阅读(143) 评论(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 telephone buttons) is given below.Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", &q 阅读全文
posted @ 2014-02-01 06:08 Averill Zheng 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
posted @ 2014-02-01 04:41 Averill Zheng 阅读(150) 评论(0) 推荐(0) 编辑
摘要: There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[... 阅读全文
posted @ 2014-01-31 04:10 Averill Zheng 阅读(152) 评论(0) 推荐(0) 编辑
摘要: A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2014-01-31 03:05 Averill Zheng 阅读(199) 评论(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 another array, you must do this in place with constant memory.For example,Given input array A =[1,1,2],Your function should return length =2, and A is 阅读全文
posted @ 2014-01-31 01:11 Averill Zheng 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]"and"([)]"are not. 1 阅读全文
posted @ 2014-01-31 01:09 Averill Zheng 阅读(161) 评论(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 @ 2014-01-31 00:48 Averill Zheng 阅读(164) 评论(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 @ 2014-01-30 15:36 Averill Zheng 阅读(284) 评论(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 the character'.'.A partially filled sudoku which is valid.Here is a brute force method. I do not whether there is an other smart method. 1 pub 阅读全文
posted @ 2014-01-30 09:32 Averill Zheng 阅读(138) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 下一页