[Leetcode]Top K问题总结

2021-03-06
阅读 1 分钟
4.9k
问题:找第 K 大的数在一个数组里在数据流中找最大的 K 个数在一个数组里在数据流中找出现频率最高的 K 个数在一个数组中在数据流中在文件中这种题适合各种follow up核实问题:是否需要精确的结果?数据是离线的(文件形式计算一次得到一个结果)还是在线的(数据流可无限次查询实时结果)?-问题1 - 找第 K 大的数:在一个...

[设计题] 17道经典设计题串讲

2016-07-21
阅读 7 分钟
19.3k
最近正在面试uber,uber以频繁考察系统设计而著名,系统设计是一个没有标准答案的open-end问题,所以关键在于对于特定问题的设计选择,俗称trade-off,这个思维平时无处锻炼,故开启此文,记录学习和理解的过程。 本文全部题目和分析来自《Elements Of Programming Interviews》的 Design Problems 章节,我只是在他的基...

[Leetcode] Word Search I&II 二维字符矩阵查找单词

2016-06-13
阅读 7 分钟
4.6k
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 horizontally or vertically neighboring. The same >letter cell may not be used more than once. For example, Given board = {...

[基本算法] Detect Cycle in Directed/Undirected Graph 有向图/无向图找环

2016-06-11
阅读 6 分钟
13.3k
Given n nodes labeled from 0 to n - 1 and a list of directed edges (each edge is a pair of nodes), write a function to check whether the graph contains a cycle. if edges = [0, 1], [1, 2], [0, 2]], it means 0 -> 1, 1 ->2, 0 -> 2. edges[i is parent, edgesi is child. For example: Given n = ...

[Leetcode] Graph Valid Tree 判断一个图是否为树

2016-06-11
阅读 4 分钟
11.5k
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. For example: Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true. Given n = 5 and edges = [[0, 1], [1, 2], [2,...

[Leetcode] Max Points on a Line 直线上最多的点数

2016-06-08
阅读 3 分钟
9.6k
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

[Leetcode] Palindrome Number 回文数

2016-06-07
阅读 2 分钟
2.5k
Determine whether an integer is a palindrome. Do this without extra space.

[Leetcode] Basic Calculator/Evaluate Expression 设计计算器/中缀表达式求值

2016-06-06
阅读 6 分钟
5.6k
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero. You may assume that the given expression is always valid. Some examples: "3+2*2...