摘要:Unique Binary Search Trees IIGiven n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, yo...
阅读全文
摘要:题目是:有2个10G的数据库,存储了一些string. 2者之间有一些重复的数据。请把它们合并为一个数据库,并且去除重复。限制:内存是4G例如: DB1: cmu, ucb, stanford, nyu DB2: ucsb, ucb, ucsd, cmu.两者合并后,应该是: DB: cmu,...
阅读全文
摘要:Google面试题股市上一个股票的价格从开市开始是不停的变化的,需要开发一个系统,给定一个股票,它能实时显示从开市到当前时间的这个股票的价格的中位数(中值)。SOLUTION 1:1.维持两个heap,一个是最小堆,一个是最大堆。2.一直使maxHeap的size大于minHeap.3. 当两边si...
阅读全文
摘要:Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the lar...
阅读全文
摘要:PermutationSequence https://oj.leetcode.com/problems/permutation-sequence/The set [1,2,3,…,n] contains a total of n! unique permutations.By listing a...
阅读全文
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen...
阅读全文
摘要:SubsetsGiven a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set mus...
阅读全文
摘要:Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol...
阅读全文
摘要:Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and ...
阅读全文
摘要:Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos...
阅读全文
摘要:First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Yo...
阅读全文
摘要:Best Time to Buy and Sell Stock IIIQuestion SolutionSay you have an array for which the ith element is the price of a given stock on day i.Design an a...
阅读全文
摘要:Best Time to Buy and Sell Stock IIQuestion SolutionSay you have an array for which the ith element is the price of a given stock on day i.Design an al...
阅读全文
摘要:Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl...
阅读全文
摘要:转自:http://www.cnblogs.com/pkuoliver/archive/2010/10/06/sotry-about-sqrt.html源码下载地址:http://diducoder.com/sotry-about-sqrt.html好吧,我承认我标题党了,不过既然你来了,就认真看下...
阅读全文
摘要:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu...
阅读全文
摘要:Longest Common Subsequence原题链接:http://lintcode.com/zh-cn/problem/longest-common-subsequence/Given two strings, find the longest comment subsequence (L...
阅读全文
摘要:Longest Common Substring原题链接:http://lintcode.com/zh-cn/problem/longest-common-substring/#Given two strings, find the longest common substring.Return t...
阅读全文
摘要:Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume...
阅读全文
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.SOLUTION 1:参见:二分法总结,以及模板:http://t.cn/RZGkPQc 1 public class Solution { 2 pu...
阅读全文
摘要:排序总结面试经验硅谷某前沿小Startup面试时,问到的一个题目就是写一个快速排序算法。进而面试官问到了各种算法的算法复杂度,进而又问了Merge Sort 与 QuickSort 的优劣。对排序算法的全面理解,体现了计算机学生的功底。现在来讲Merge Sort 与Quick Sort 是最流行的...
阅读全文
摘要:二分法模板: 1 while (l A[l]) {11 l = m;12 } else {13 r = m;14 }15 } 相关二分法题目链接:L...
阅读全文
摘要:Search in Rotated Sorted Array IIFollow up for "LeetCode: Search in Rotated Sorted Array 解题报告":What ifduplicatesare allowed?Would this affect the run-...
阅读全文
摘要:Search in Rotated Sorted ArraySuppose 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)....
阅读全文
摘要:Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callin...
阅读全文
摘要:Search Insert PositionGiven 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 ...
阅读全文