- 博客(39)
- 资源 (2)
- 收藏
- 关注
原创 cracking the code interview problem 1.3
//Given two Strings,write a method to decide if one is a permutation of the other.//ask what the complexity of time, can we use sort first?//if we can use sort:public class Solution { public stati
2014-02-19 04:05:16 1152
原创 cracking the code interview problem 1.1
public class Solution { public static boolean isUnique(String str){ if(str.length()>256) return false; boolean[] visited = new boolean[256]; for(int i=0;i<str.length();i++){ int val = str
2014-02-19 04:04:13 807
原创 Binary Tree Traversal 3 种
百度这张图说明了所有问题,前序遍历得到的结果,root 在最前方。后序遍历得到的结果,root在最后。中序遍历得到的结果,root 在中央。所以leetcode上有关traversal的题目,给定preorder 和 inorder 的结果,tree可还原。给定postorder和inorder的结果,tree可还原。
2014-02-13 03:59:59 1094
原创 leetcode JAVA Palindrome Partitioning 3.45 难度系数3
Question: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
2014-02-11 00:58:06 1163
原创 leetcode JAVA Word Ladder 3.44 难度系数3
Question: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 inte
2014-02-11 00:56:48 1017
原创 leetcode JAVA Best Time to Buy and Sell Stock II 3.43 难度系数3
Question:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you l
2014-02-11 00:54:56 919
原创 leetcode JAVA Triangle 难度系数3 3.42
Question:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2],
2014-02-05 11:34:11 760
原创 leetcode JAVA Populating Next Right Pointers in Each Node 难度系数3 3.41
Question:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its ne
2014-02-05 11:33:02 967
原创 leetcode JAVA Flatten Binary Tree to Linked List 难度系数3 3.40
Question:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look
2014-02-05 11:31:48 1450
原创 leetcode JAVA Binary Tree Level Order Traversal II 难度系数3 3.39
Question:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9
2014-02-05 11:30:12 952
原创 leetcode Construct Binary Tree from Inorder and Postorder Traversal 难度系数3 3.38
Question:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definition for binary tree * publ
2014-02-05 11:27:46 1165
原创 leetcode JAVA Construct Binary Tree from Preorder and Inorder Traversal 难度系数3 3.37
Question:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definition for binary tree * publi
2014-02-05 11:26:45 1727
原创 leetcode JAVA Binary Tree Level Order Traversal 难度系数3 3.36
Question:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 /
2014-02-05 11:25:07 1252
原创 leetcode JAVA Validate Binary Search Tree 难度系数3 3.35
Question: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 th
2014-02-05 11:22:51 819
原创 leetcode JAVA Unique Binary Search Trees 难度系数3 3.34
Question: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
2014-02-05 11:21:35 1297
原创 leetcode JAVA Restore IP Addresses 难度系数3 3.33
Question: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.11
2014-02-05 11:20:12 858
原创 leetcode JAVA Reverse Linked List II 3.32
Question: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 the follow
2014-02-05 11:18:22 1040
原创 leetcode JAVA Decode Ways 难度系数3 3.31
Question: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, determi
2014-02-05 11:17:11 889
原创 leetcode JAVA Partition List 难度系数3 3.30
Question:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the n
2014-02-05 10:05:40 917
原创 leetcode JAVA Remove Duplicates from Sorted List II 难度系数3 3.29
Question:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->
2014-02-01 11:36:25 1153
原创 leetcode JAVA Word Search 难度系数3 3.28
Question: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 horizontall
2014-02-01 11:35:00 5963 3
原创 leetcode JAVA Subsets 难度系数3 3.27
Question: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 contain duplicate subsets.
2014-02-01 11:33:52 1955
原创 leetcode JAVA Combinations 难度系数3 3.26
Question: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
2014-02-01 11:32:29 1115
原创 leetcode JAVA Search a 2D Matrix 难度系数3 3.25
Question:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first
2014-02-01 11:30:34 2147
原创 leetcode JAVA Set Matrix Zeroes 难度系数3 3.24
Question:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward sol
2014-02-01 11:28:52 1280
原创 leetcode JAVA Simplify Path 难度系数3 3.23
Question:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner C
2014-02-01 11:27:44 763
原创 leetcode JAVA Minimum Path Sum 难度系数3 3.22
Question:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either d
2014-02-01 11:23:29 1023
原创 leetcode JAVA Unique Paths II 难度系数3 3.21
Question: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 respect
2014-02-01 11:22:06 2702
原创 leetcode JAVA Rotate List 难度系数3 3.20
Question:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL./** * Definition fo
2014-02-01 11:20:47 966
原创 leetcode JAVA Spiral Matrix II 难度系数3 3.19
Question:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ],
2014-02-01 11:18:42 1481
原创 leetcode JAVA Jump Game 难度系数3 3.18
Question: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.
2014-02-01 11:16:40 933
原创 leetcode JAVA Maximum Subarray 难度系数3 3.17
Question: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,−5,4],the contiguous subarra
2014-02-01 11:15:41 658
原创 leetcode JAVA Pow(x, n) 难度系数3 3.16
Question:Implement pow(x, n).public class Solution { public double pow(double x, int n) { if (n >= 0) return positivePow(x, n); return 1 / positivePow(x, -n); } private double positi
2014-02-01 11:11:09 1854
原创 leetcode JAVA Anagrams 难度系数3 3.15
Question:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.import java.util.Hashtable;public class Solution { public Arra
2014-02-01 11:06:39 1011
原创 leetcode JAVA Permutations 难度系数3 3.14
Question: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], [
2014-02-01 10:56:00 807
原创 leetcode JAVA Combination Sum 难度系数3 3.13
Question: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
2014-02-01 10:51:15 2427
原创 leetcode JAVA Substring with Concatenation of All Words 难度系数3 3.12
Question: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 a
2014-02-01 10:48:01 1324
原创 leetcode Merge k Sorted Lists 难度系数3 3.11
Question:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.public class Solution { public ListNode mergeKLists(ArrayList lists) { if (lists.s
2014-02-01 10:46:02 1428
原创 leetcode Generate Parentheses 难度系数3 3.10
Question:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()",
2014-02-01 10:43:52 913
基于android的医疗记录安全
2013-12-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人