Diameter of Tree
Definition of diameter In a given tree, the diameter is defined as the longest path between any two nodes. For instance, the diameter of th…
Definition of diameter In a given tree, the diameter is defined as the longest path between any two nodes. For instance, the diameter of th…
Timer on ProcessFunction and KeyedProcessFunction Flink distinguishes between two key notions of time: processing time and event time. Proc…
Stream API (SourceFunction, AbstractSourceFunction and RichSourceFunction) in Flink In Flink's streaming API, there is a critical interface…
Manhattan Distance Definition: The Manhattan distance between two points $(x_1, y_1)$ and $(x_2, y_2)$ in a 2D plane is defined as $dis = |…
Why Dynamic Segment Tree? As know for segment tree, the space complexity is is up to 4 n, which n is upper bound of data range. However, :-…
前言 Goroutine是Golang中实现的协程,它保证了Golang的高并发的可用性,这些Goroutine分配、负载、调度到处理器上采用的是G-M-P模型。 进程、线程、Goroutine 进程是操作系统进行资源分配调度的最小单元,而线程则是CPU进行调度的最小单元。进程…
引言 Covey在书中用一个小例子描述了“个人看法的重要性”,他儿子在学校的表现不尽人意,做父母的经常鼓励孩子,然而却是于事无补,随着Covey对儿子的看法转变,即便是不刻意鼓励孩子,他也能飞快的进步。也即引出了书中最为重要的观点:“为了达成真正的改变,必须对自我认知做出改变,…
Timeline & Search 简介 系统设计中,时间线(timeline)功能是十分常见的,诸如朋友圈,微博,Twitter等社交平台都会涉及到,主要功能就是按时间线看到已经关注的人发送的消息。而搜索功能则是公开社交平台的重要功能。 Pull vs. Push 为了实现时…
给定一个公共API,限制每个用户每秒只能调用1000次,如何实现?这个一个经典的API限速问题(API rate limiting)。 初始想法 最朴素的想法就是给每一个用户配额,此时为Q,在第一次调用的时候分配给用户,然后在接下来的时间段,如果访问的此时大于Q,就直接拒绝用户…
雪花算法能解决什么问题? 雪花算法能够生成全局唯一的ID编码作为其他地方的标记。且生成一系列的ID满足如下的性质: 生成的系列ID是递增的 高可用性:任何时候都能够生成唯一的ID 再高并发的条件下也能够保证服务 SnowFlake的组成 最高位是符号位,始终为0 41位的时间戳…
图 简单来说,图是由一组点和相对应边组成的,可以表示为G=<V,E>,V为Vertex(点集),E为Edge(边集)。细分下来根据点集之间的对等关系又可以分为,有向图(又可分为带权和无权有向图),无向图,混合图。图中点包含的另外一个的重要信息就是各自的出度(outdeg)和入度…
字符串匹配算法 匹配的目的就是给定两个字符串,s 和 pattern, pattern是要查找的字符串,s是被查找的文本,要求找到pattern在s中第一次出现的位置,假定pattern为 acd, s为acfgacdem, 那么s在t中第一次出现的位置就是4。常见的匹配算法有…