https://leetcode.com/problems/minimum-cost-to-hire-k-workers/description/ https://chenboxie.wordpress.com/2018/09/30/leetcode-857-minimum-cost-to-hire-k-workers/
https://leetcode.com/problems/count-complete-tree-nodes/description/
如果没有complete tree这个特性,就是递归,计算左子树node个数和右子树节点个数,然后相加再加root,要利用complete tree的特性,如果这个树最左和最右的深度是相同的,代表这个树是不存在缺口的,就可以直接用2^d – 1来求。
https://leetcode.com/problems/evaluate-division/description/
https://chenboxie.wordpress.com/2018/06/29/leetcode-399-evaluate-division/
https://leetcode.com/problems/design-search-autocomplete-system/description/
这道题注意要把Trie的实现和AutoComplete System合并,不要单列个Trie的实现出来
https://leetcode.com/problems/number-of-corner-rectangles/description/
两行同时遍历,如果两行中相同列位置的值都为1,则计数器cnt自增1,那么最后就相当于有了(cnt – 1)个相邻的格子,问题就转化为了求cnt-1个相邻的格子能组成多少个矩形,共有cnt*(cnt-1)/2个. 时间复杂度O(m*m*n)
Read full article from Google面经 – Matthew Xie
No comments:
Post a Comment