摘要:
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... 阅读全文