August 2025

interview-skills

系统设计总结

系统设计的题目,感觉不用做非常多,但要善于总结,相似的问题可以总结成一类,用一个模板来解答,然后加一些小细节加以区分。 如何将一个信息同时传播给多个关注该事务的client 定时任务 Event Sourcing Event sourcing就是说我们不存最后的状态,而是把每一个action都存起来,然后需要结果的话,我们得到所有的action,然后derive出最后的状态是什么。那什么时候需要event sourcing呢?跟钱打交道的时候,比如说Auction system需要我们prove为什么是这个人赢得了最后的bid等。另一个就是,如果很多人都在竞拍一个产品,如果我们只存最终结果(在这种情况下是update Auction表里的winner),在高并发的情况下会一直修改同一个数据,这要比往bid table里不停append给bid table的的性能要差很多。 Lease机制 Lease机制是facebook设计memcached的时候,为了解决数据一致性的问题解决的,非常适合高并发场景。那么是如何工作的呢?– 同一个cache key,memcached维护一个当前有效的lease token,不管多少请求都拿到这个token– server A和server B都来读取数据,拿到相同token,然后server […]

frontend

JavaScript

JS特性 JavaScript代码能放在哪里? 也可以将javascript代码写入一个外部的js文件当中,然后通过script标签进行导入。写入外部文件的好处是不同的html页面都可以引用它,也可以利用到浏览器的缓存机制。是比较推荐的一种方式。 注意:script标签一旦用于引入外部文件,就不能在标签体里面写js代码了,即使写了浏览器也会忽略的。如果头铁,非得写,那就在新建一个script标签。 注释 注释有单行注释或者多行注释 数据类型 六种基本的数据类型: 前五种为基本数据类型,而Object属于引用数据类型。 判断一个变量的类型,可以用typeof来检查。 Number.MAX_VALUE -> JS数字的最大值,超过该值就会显示Infinity。NaN -> Not a number,如果用typeof来检查,还是会显示为number。Number.MIN_VALUE -> 0以上的最小的数字,表示正的最小数。null专门用来表示一个为空的对象。如果用typeof检查,会返回“object”。当申明一个变量但不给变量赋值时就是undefined,用typeof检查就是”undefined”。 强制类型转换

interview-skills

搜索

什么情况下用BFS? 什么情况下用DFS? 练习题 https://leetcode.com/problems/combination-sum/description https://leetcode.com/problems/combination-sum-ii/description https://leetcode.com/problems/palindrome-partitioning https://leetcode.com/problems/permutations/description https://leetcode.com/problems/permutations-ii/description

interview-skills

动态规划

什么题适合动态规划? 什么题不适合动态规划? 动规四要素 顺带回忆一下递归三要素 动态规划只能记录一种最优方案 练习题目: https://leetcode.com/problems/triangle/description https://leetcode.com/problems/minimum-path-sum/description https://leetcode.com/problems/unique-paths/description https://leetcode.com/problems/climbing-stairs/description https://leetcode.com/problems/longest-increasing-subsequence/description https://leetcode.com/problems/perfect-squares/description https://leetcode.com/problems/largest-divisible-subset/description https://leetcode.com/problems/russian-doll-envelopes/description https://leetcode.com/problems/frog-jump/description

Scroll to Top