摘要:
LRU Least Recently Used 最近最少使用算法 LRU可以算是书本中比较熟悉的算法了,有缓存存在的场景下,基本都会有它的身影。它的作用就是在空间一定的缓存中,淘汰掉最近最少使用的数据,这样就有空间容纳新的数据。 那么假如需要设计一个类似LRU的算法,要支持获取数据get和插入数据p 阅读全文
摘要:
BlockingQueue阻塞队列 A Queue that additionally supports operations that wait for the queue to become non-empty when retrieving an element, and wait for s 阅读全文
摘要:
Executor Executor Executor 是J.U.C的一个接口,用来处理多线程的。直接说这个可能不太熟,但是大名鼎鼎的ThreadPoolExecutor就是实现了这个接口。 public interface Executor { /** * Executes the given co 阅读全文
摘要:
Print Binary Tree Top to Bottom 从上到下打印二叉树 从上到下按层打印二叉树,一层从左到右打印。 思路 使用queue完成对树的层序遍历 /** * Definition for a binary tree node. * public class TreeNode { 阅读全文
摘要:
Invert Binary Tree 翻转二叉树 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() 阅读全文