Fork me on GitHub
上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页
摘要: LRU Least Recently Used 最近最少使用算法 LRU可以算是书本中比较熟悉的算法了,有缓存存在的场景下,基本都会有它的身影。它的作用就是在空间一定的缓存中,淘汰掉最近最少使用的数据,这样就有空间容纳新的数据。 那么假如需要设计一个类似LRU的算法,要支持获取数据get和插入数据p 阅读全文
posted @ 2021-06-06 11:18 WilliamCui 阅读(64) 评论(0) 推荐(0) 编辑
摘要: Construct Binary Tree from Preorder and Inorder Traversal 从前序与中序遍历序列构造二叉树 通过preorder 和inorder,构造一棵二叉树 思路 问题不复杂,有了前序和中序,可以恢复一棵二叉树。 前序里面打头的肯定是root 中序里面的 阅读全文
posted @ 2021-04-28 10:33 WilliamCui 阅读(69) 评论(0) 推荐(0) 编辑
摘要: BlockingQueue阻塞队列 A Queue that additionally supports operations that wait for the queue to become non-empty when retrieving an element, and wait for s 阅读全文
posted @ 2021-04-26 10:45 WilliamCui 阅读(63) 评论(0) 推荐(0) 编辑
摘要: Path Sum 路径和 给一个二叉树,和sum,判断是否存在一条路径上的节点之和等于sum Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 Output: true 思路 递归向下求解,直到叶子节点并且 阅读全文
posted @ 2021-04-26 10:42 WilliamCui 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Executor Executor Executor 是J.U.C的一个接口,用来处理多线程的。直接说这个可能不太熟,但是大名鼎鼎的ThreadPoolExecutor就是实现了这个接口。 public interface Executor { /** * Executes the given co 阅读全文
posted @ 2021-04-25 09:22 WilliamCui 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Balanced Binary Tree 平衡二叉树 给一个二叉树,判断是否为平衡二叉树。 平衡二叉树:一个二叉树*每个节点* 的左右两个子树的高度差的绝对值不超过 1 Input: root = [3,9,20,null,null,15,7] Output: true Input: root = 阅读全文
posted @ 2021-04-23 14:12 WilliamCui 阅读(64) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Zigzag Level Order Traversal 二叉树的锯齿形层序遍历 给一个二叉树的root,返回其节点值从上到下遍历,奇数层从左到右 遍历,偶数层从右到左。 Input: root = [3,9,20,null,null,15,7] Output: [[3],[ 阅读全文
posted @ 2021-04-23 09:23 WilliamCui 阅读(60) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Level Order Traversal 2 二叉树层序遍历 给一个二叉树的root,返回其节点值从低向上遍历,每一层从左到右 遍历。 Input: root = [3,9,20,null,null,15,7] Output: [[15,7],[9,20],[3]] /** 阅读全文
posted @ 2021-04-22 10:27 WilliamCui 阅读(64) 评论(0) 推荐(0) 编辑
摘要: Print Binary Tree Top to Bottom 从上到下打印二叉树 从上到下按层打印二叉树,一层从左到右打印。 思路 使用queue完成对树的层序遍历 /** * Definition for a binary tree node. * public class TreeNode { 阅读全文
posted @ 2021-04-22 10:24 WilliamCui 阅读(65) 评论(0) 推荐(0) 编辑
摘要: Invert Binary Tree 翻转二叉树 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() 阅读全文
posted @ 2021-04-21 09:35 WilliamCui 阅读(72) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页