发布了文章2021-03-06
问题:找第 K 大的数在一个数组里在数据流中找最大的 K 个数在一个数组里在数据流中找出现频率最高的 K 个数在一个数组中在数据流中在文件中这种题适合各种follow up核实问题:是否需要精确的结果?数据是离线的(文件形式计算一次得到一个结果)还是在线的(数据流可无...
发布了文章2018-01-18
一个类只干一件事,这件事只有一个部门(cfo/ceo/coo)可以改变, don't put functions that can be changed for different reasons in the same class
发布了文章2016-12-11
工作之后代码都是业务逻辑,与算法题很不一样。在研究公司代码库时发现很多设计模式的应用,于是打算系统地学习Design Pattern。想要达到的目的是,给一个需求,能够迅速知道哪种设计模式可以应用,然后分析在这个情境中是否应该用这个设计模式,还是组合多个设计模...
赞了文章2016-12-11
近一年没有写代码了,手痒无聊,集中刷了近一百题,前一半按序全部做了,后面的挑了有意思的做,一眼看起来太简单的且重复类型的就忽略了。最近挑的题,发现没有了自测按钮,不太方便。暂时不再刷题了。开启新的一章,学习“机器学习”,从入门开始,看书、上公开课、...
发布了文章2016-07-30
用爬山来比喻回溯,好比从山脚下找一条爬上山顶的路,起初有好几条道可走,当选择一条道走到某处时,又有几条岔道可供选择,只能选择其中一条道往前走,若能这样子顺利爬上山顶则罢了,否则走到一条绝路上时或者这条路上有一坨屎,我们只好返回到最近的一个路口,重新选择另...
赞了文章2016-07-25
题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
发布了文章2016-07-21
最近正在面试uber,uber以频繁考察系统设计而著名,系统设计是一个没有标准答案的open-end问题,所以关键在于对于特定问题的设计选择,俗称trade-off,这个思维平时无处锻炼,故开启此文,记录学习和理解的过程。 本文全部题目和分析来自《Elements Of Programming In...
发布了文章2016-07-20
Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space.
赞了文章2016-07-20
题目:The API: int read4(char *buf) reads 4 characters at a time from a file.
赞了文章2016-07-15
题目:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
赞了文章2016-07-15
题目:Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 + bx + c to each element x in the array.
发布了文章2016-07-14
Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and is placed on an empty block.Once a winning condition is reached, no more moves is allowed.A play...
赞了文章2016-07-12
题目:Given a nested list of integers, return the sum of all integers in the list weighted by their depth.
赞了文章2016-07-12
题目:You are given a m x n 2D grid initialized with these three possible values.
赞了文章2016-07-12
题目:Given an integer matrix, find the length of the longest increasing path.
发布了文章2016-07-12
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example:Given binary tree {代码...} Returns [4, 5, 3], [2], [1]. Explanation: Removing the leaves [4, 5, 3] would...
发布了文章2016-07-10
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0. If there are multiple solutions, return any subset is fine. Example 1: nums: [1,2,3]...
发布了文章2016-06-26
Numbers can be regarded as product of its factors. For example, {代码...} Write a function that takes an integer n and return all possible combinations of its factors. Note: You may assume that n is always positive.Factors should be greater than 1...
发布了文章2016-06-25
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in the tree, return null.
发布了文章2016-06-24
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1Input: "2-1-1". {代码...} Output: [0, 2] Example 2Inpu...