摘要:
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ... 阅读全文
摘要:
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
摘要:
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.计算N皇后的合法解的数量。解题思路:这次使用了更优化的... 阅读全文
摘要:
Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For exampl... 阅读全文
摘要:
公司在推一个大项目,感觉阿里云挺好用的,自己搞了台小机器平时可以跑着玩,而且可以做个跳板机,平时学校里的收费网直接用跳板机就可以访问了,直接写个脚本在自己机器上跑一下:#!/usr/bin/expect -fset timeout -1spawn ssh -qTNf -D 127.0.0.1:123... 阅读全文
摘要:
Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题目大意:给定一个组区间,实... 阅读全文
摘要:
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c... 阅读全文
摘要:
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According ... 阅读全文
摘要:
Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文
摘要:
蓄水池算法要解决的问题就是在不知道流入数据量多少的情况下,依旧可以随机从这些数中选取K个,乍一听好神奇,其实分析一下背后的概率知识,思想还是很简单的,相信看完我的介绍和证明,你也会觉得很简单。假设要求随机选择K个元素,假设一共流入的元素有n个。 首先数组a[0...k-1]表示最后返回的结果,最开... 阅读全文