20260731

20260730

20260729

An NS (Name Server) record tells the internet which DNS servers are authoritative for a domain or subdomain — i.e., “ask these servers for this zone’s DNS answers.”

In other words, an NXDOMAIN error message simply indicates that the domain does not exist.

20260728

20260727

A local LLM consists of model weights, a model architecture definition, and a tokenizer. The weights are just learned numerical parameters; they cannot generate text on their own. An inference engine (such as llama.cpp, MLX-LM, Hugging Face Transformers, or vLLM) implements the model architecture, loads the weights, tokenizes the input, performs the neural network computations, and generates text. Ollama is not itself the inference algorithm—it is a runtime and management layer that wraps an inference engine, handling model downloads, loading/unloading, and providing a simple CLI and HTTP API. Finally, the tokenizer is tied to the model, because the model was trained using that specific mapping between text and token IDs; using a different tokenizer generally leads to incorrect or degraded results.

I saw someone tried to load Chinise models locally, and I got curious about that.

20260726

20260725

I felt frustrated for no reasons today.

20260724

20260723

20260722

I want to spend some time doing LeetCode tomorrow.

20260721

20260720

20260719

20260718

20260717

20260716

class Solution:
    def isPowerOfThree(self, n: int) -> bool:
        if n <= 0:
            return False

        return 3 ** 19 % n == 0

20260715

20260714

class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        # 4 ≡ 1 (mod 3)
        # 4^k ≡ 1^k ≡ 1 (mod 3)

        if n <= 0:
            return False

        if n & (n - 1) != 0:
            return False

        return n % 3 == 1

20260713

class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        # 1 -> 1
        # 4 -> 100
        # 16 -> 10000

        if n <= 0:
            return False

        if n & (n - 1) != 0:
            return False

        EVEN_BIT_MASK = 0x55555555
        return n & EVEN_BIT_MASK != 0

20260712

CPU Core
   │
Registers    (~1 KB, fastest)
   │
L1 Cache     (~32–64 KB)
   │
L2 Cache     (~256 KB–2 MB)
   │
L3 Cache     (~8–64 MB)
   │
RAM          (GBs)
   │
SSD / HDD    (TBs)

The number of cache levels in a CPU is a design choice that balances speed, capacity, power, and cost.
class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        return (
            n > 0  # 4 ^ x cannot be negative
            and n & (n - 1) == 0  # exactly one bit is set
            and n & 0x55555555 == n  # 1 bit at even position - 4 ^ x
            # and (n & 0x55555555) != 0  # alternative
        )

20260711

# I know this solution does not pass the test cases
# This is just for my reference
import collections


class Solution:
    def findMinHeightTrees(self, n: int, edges: list[list[int]]) -> list[int]:
        node_to_neighbors = collections.defaultdict(list)
        for node1, node2 in edges:
            node_to_neighbors[node1].append(node2)
            node_to_neighbors[node2].append(node1)

        def get_height(node: int, parent: int) -> int:
            return max(
                (
                    get_height(neighbor, node)
                    for neighbor in node_to_neighbors[node]
                    if neighbor != parent
                ),
                default=0
            ) + 1

        min_height = float("inf")
        min_roots = []
        for node in range(n):
            height = get_height(node, None)
            if height > min_height:
                continue
            elif height < min_height:
                min_height = height
                min_roots = [node]
            else:  # height == min_height
                min_roots.append(node)

        return min_roots

20260710

20250709

20260708

20260707

20250706

20260621-20260705


index 202606 202608