文章分类 - 算法与数据结构
摘要:想法源自力扣第88场双周赛最后一题,https://leetcode.cn/problems/number-of-pairs-satisfying-inequality/ 有思路但是没有合适的方法,事后看题解发现有人使用了python的SortedList,遂尝试用ts也写一个相同功能的工具类,本质
阅读全文
摘要:class TopSort { // 邻接表 private readonly map: Set<number>[] // 所有节点的入度 private readonly rd: number[] // 节点数量k,边集合arr,是否使用序号0 constructor(k: number, arr
阅读全文
摘要:2022-09-12更新,更好修改的版本 class SegmentTree { // 堆 public arr: number[] constructor(n: number = 0, fill: number = 0) { this.arr = new Array(n * 4) this.arr
阅读全文
摘要:本文参考:https://labuladong.github.io/algo/2/21/52/ 2022.7.30更新 新增节点数优化,合并时将节点数少的树并入节点数多的树中,减少对子节点的操作次数 class UnionFind { // 联通分量数目 public size: number =
阅读全文
摘要:class TreeNode<T> { public val: T public left: TreeNode<T> | null public right: TreeNode<T> | null constructor(val: T, left: TreeNode<T> | null = null
阅读全文
摘要:自己随便写的,看看就好 class BookTree { public keys: Map<String, BookTree> public has: boolean constructor() { this.keys = new Map<String, BookTree>() this.has =
阅读全文
摘要:本文参考:https://labuladong.github.io/algo/2/21/62/ 2022.7.24更新 新增remove(删除)、update(更新)函数 // 优先队列 class PriorityQueue<T> { // 队列本体,二叉堆,注意arr[0]未使用 private
阅读全文

浙公网安备 33010602011771号