remove(), two pointersremove(), two pointers (I felt some of the dots in me
were connected, Dutch Flag)dig, NS record, NXDOMAINAn 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.
git branch -m (--move)get_longest_path())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.
I felt frustrated for no reasons today.
I want to spend some time doing LeetCode tomorrow.
caffeinategh
git push --force-with-leaseclass Solution:
def isPowerOfThree(self, n: int) -> bool:
if n <= 0:
return False
return 3 ** 19 % n == 0
containeris a tool that you can use to create and run Linux containers as lightweight virtual machines on your Mac. It’s written in Swift, and optimized for Apple silicon.
n & (n - 1) == 0, loopclass 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 == 1class 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 != 02^10 = 1024 =~ 10 ^ 3n & (n - 1) == 0CPU 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
)# 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