DP
[toc]
OVERVIEW:Five Steps:
DP Array (DP Table) and Index Meaning:
The DP array (dp) is a table where each entry dp[i] represents the solution to a subproblem related to the problem you’re solving.
The index i typically corresponds to some parameter or state in the problem, such as length, position, or another relevant metric.
Recurrence Relation (Recursive Formula):
This is the formula that defines how to compute dp[i] based on previously computed values in the DP table and possibly other inp ...
Greedy
[toc]
Greedy AlgorithmThe greedy algorithm generally consists of the following four steps:
Divide the problem into several subproblems: Break down the main problem into smaller, manageable subproblems.
Find a suitable greedy strategy: Identify an appropriate greedy strategy that will help in making the optimal choice at each step.
Solve each subproblem optimally: Apply the greedy strategy to solve each subproblem and find the local optimum.
Stack the local optima to form the global optimum: Com ...
💐Linear Neural Networks for Regression💐
[TOC]
Linear RegressionBasics
3.1.2. Vectorization for Speed
3.1.3. The Normal Distribution and Squared Loss
3.1.4. Linear Regression as a Neural Network
3.1.5. Summary
3.1.6. Exercises
3.2. Object-Oriented Design for Implementation
3.2.1. Utilities
3.2.2. Models
3.2.3. Data
3.2.4. Training
3.2.5. Summary
3.2.6. Exercises
3.3. Synthetic Regression Data
3.3.1. Generating the Dataset
3.3.2. Reading the Dataset
3.3.3. Concise Implementation of the Data Loader
3.3.4. Summary
3.3.5. Exercises
3.4. ...
💐Preliminaries💐
[TOC]
online readingPreliminariesData Manipulationdata manipulation vs. data preprocessingData Preprocessing: A comprehensive process that includes data manipulation to prepare raw data for analysis and modeling.
Data Manipulation: A subset of preprocessing tasks focused on transforming and organizing data.
data preprocessing includes data manipulation
Data ManipulationDefinition: Data manipulation refers to the process of changing data to make it more organized and easier to analyze. This inclu ...
Backtracking
[toc]
Backtrackingoverview
纯暴力的搜索算法
组合问题:N个数里面按一定规则找出k个数的集合
切割问题:一个字符串按一定规则有几种切割方式
子集问题:一个N个数的集合里有多少符合条件的子集
排列问题:N个数按一定规则全排列,有几种排列方式
棋盘问题:N皇后,解数独等等回溯法都可以抽象为树形结构
回溯搜索的遍历过程
在上面我们提到了,回溯法一般是在集合中递归搜索,集合的大小构成了树的宽度,递归的深度构成的树的深度。
如图:
注意图中,我特意举例集合大小和孩子的数量是相等的!
回溯函数遍历过程伪代码如下:
12345for (选择:本层集合中元素(树中节点孩子的数量就是集合的大小)) { 处理节点; backtracking(路径,选择列表); // 递归 回溯,撤销处理结果}
for循环就是遍历集合区间,可以理解一个节点有多少个孩子,这个for循环就执行多少次。
backtracking这里自己调用自己,实现递归。
大家可以从图中看出for循环可以理解是横向遍历,backtracking(递归)就是纵向 ...
DOF-GS with Joint Camera Optimization
config conda environment123456xdantong@longleaf-login6 dof gaussian camoptim]$ module unload pythonxdantong@longleaf-login6 dof gaussian camoptim]$ module load anaconda/2021.11xdantong@longleaf-login6 dof gaussian camoptim]$ conda --versionconda 4.12.0
pip install torch==2.0.1 torchvision==0.15.2 torch-cluster==1.6.3 torchaudio==2.0.2 -f https://download.pytorch.org/whl/torch_stable.html
1conda activate dof_gs
12345(dof_gs) [xdantong@longleaf-login4 do ...
Tree
[toc]
TREEBinary trees can be classified based on their structure and properties. Here are the main classifications of binary trees:
Based on Node Relationships
Full Binary Tree:
Every node has either 0 or 2 children.
Also known as a strictly binary tree.
Complete Binary Tree:
All levels are completely filled except possibly for the last level.
The last level has all nodes as left as possible.
Perfect Binary Tree:
All internal nodes have two children, and all leaf nodes are at the same ...
Stack
[toc]
Stack
What is a stack?
Answer: A stack is a linear data structure that follows the Last In, First Out (LIFO) principle, where the last element added to the stack is the first one to be removed. Common operations include push (to add an element), pop (to remove the top element), and peek (to view the top element without removing it).
What are the primary operations of a stack?
Answer:
The primary operations of a stack are:
push(x): Add element x to the top of the stack.
pop(): Remove ...
String
[toc]
String344. Reverse StringEasy
Write a function that reverses a string. The input string is given as an array of characters s.
You must do this by modifying the input array in-place with O(1) extra memory.
Example 1:
12Input: s = ["h","e","l","l","o"]Output: ["o","l","l","e","h"]
12345678910111213class Solution { public void reverseString(char[] s) { int left = 0; ...
Hash
[toc]
HashOverview当我们遇到了要快速判断一个元素是否出现集合里的时候,就要考虑哈希法。
hashmap
hashset
242. Valid AnagramGiven two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1:
12Input: s = "anagram", t = "nagaram"Output: true
1234567891011121314151617class Solution { public boolean isAnagram(String s, String t) ...