辗转相除法:GCD 与 LCM
力扣中的许多题都涉及求最大公约数 (Greatest Common Divisor, GCD) 和最小公倍数 (Least Common Multiple, LCM)。本文记录了 GCD 与 LCM 的代码实现。 GCD 可以使用辗转相除法求解两个数的最大公约数。 递归版 class GCD { public int gcd(int a, int b) { i...
力扣中的许多题都涉及求最大公约数 (Greatest Common Divisor, GCD) 和最小公倍数 (Least Common Multiple, LCM)。本文记录了 GCD 与 LCM 的代码实现。 GCD 可以使用辗转相除法求解两个数的最大公约数。 递归版 class GCD { public int gcd(int a, int b) { i...
Basics Searching Big Search Spaces Search space: \(\{0, 1\}^n\). $2^n$ possible candidates. Assume \(\mathbf{a}^*\in \{0, 1\}^n\) is the goal vector. Size (formally called the card...
Perplexity (PPL) Perplexity is defined as the exponentiated average negative log-likelihood of a sequence. If we have a tokenized sequence \(X=(x_0, x_1, \cdots, x_t)\), then the perplexity of \(X\...
问题背景 推导 答案为 \(\Theta(N)\)。 时间复杂度为: [\begin{align} &\sum_{k = 0}^{\log N - 1} 2^k \left(\log N - k \right) =& \sum_{k = 0}^{\log N - 1} 2^k\cdot \log N - \sum_{k = 0}^{\log N - 1} k\cdo...
Introduction Search VS Recommendation Search engines Recommender systems User has an information need User has an interest User typ...
Tabular Value Based Methods Backup Monte-Carlo backup: zero bias, high variance. [\begin{align} V(S_t) \leftarrow V(S_t) + \alpha(G_t - V(S_t)) \end{align}] Temporal difference backup: hig...
《C++ Primer》读书笔记。 基本作用 const 对象创建后,值不能再改变。 初始化: int i = 42; const int ci = i; // 正确:i 的值被拷贝给了 ci int j = ci; // 正确: ci 的值被拷贝给了 j 默认情况下,const 对象仅在文件内有效。 需要文件间共享时,使用 extern 关键字。 ...
Inspired by Scott H. Young’s MIT challenge and TeachYourselfCS, I decided to embark on a self-study project called UltraCS challenge. How far can I go in CS field? The following is the schedule of...
Tasks Case: Discover side effects for hypertension medications. The text mining pipeline: Filter the data: Retrieve relevant messages. Process the data: Clean, anonymize. Create training dat...
Basics Hash function: A hash function maps hash-keys of some data type to integer bucket numbers. A good hash function distributes the possible hash-key values approximately evenly among buckets. A...