haruhiui
Starlight

haruhiui

= 約束タワーで待ってて =

最新文章

ASTC Texture Format

# ASTC 纹理格式 ![image-20240212140340603](image-20240212140340603.png) 一般的纹理压缩格式都有两个要素,color endpoint 和 weight grid,即端点颜色和权重表,具体的数据部分由权重表示,在解压时通过权重从两个端点颜色之间插值出结果颜色。 weight grid 数据部分的大小定义为 grid size。另一个和 size 相关的概念是 block size,表示将几乘几的像素一起进行压缩。ASTC 格式的压缩结果都是 128 bits,ASTC4X4 就是将 4X4 的像素压缩到 128 bits,这样
more...

Binary Exponentiation

# Binary Exponentiation Binary Exponentiation 快速幂算法,或者叫二进制取幂。 LeetCode 模板题:[50. Pow(x, n)](https://leetcode-cn.com/problems/powx-n/) 递归版: ```python bi-exp-recur.py class Solution: def myPow(self, x: float, n: int) -> float: if n < 0: return 1 / self.myPow(x, -n) if n == 0: re
more...

Lowest Common Ancestor

# LCA 一个树的 Lowest Common Ancestor 最近公共祖先。 这篇文章主要目的是在于寻找解决类似 LCA 问题的统一方法。!!就图一乐!! # 两个结点都存在 LeetCode 模板题:[236. 二叉树的最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/) ```python lc236.py # Definition for a binary tree node. # class TreeNode: # def __init__(self,
more...

Length of LIS

# Length of LIS LIS: Longest Increasing Subsequence 最长递增子序列。Length of LIS 就是求一个数组中最长子序列的长度。 [300. Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/) 总的来说,有两种方法,一种是 DP,另一种还是 DP。 第一种 DP: ```python len-LIS-1.py class Solution: def lengthOfLIS(self,
more...

Binary Tree Traversal

Binary Tree Traversal 二叉树遍历。 前序、中序、后序遍历用到的数据结构都是栈,使用 Python 的 `list` 来表示栈,有 `append()` 和 `pop()` 方法,都是 `O(1)` 时间。需要注意的是 list 的带参数的 `pop(i)` 复杂度是 `O(n)` 。(所以一般如果要用队列的话最好不要用 `list` 而是用 `collections.deque()` 的 `append()` 和 `popleft()` 来达到 `O(1)` 。) # 前序遍历 LeetCode 模板题:[144. 二叉树的前序遍历](https://leetcod
more...