Home
Cybernaut in Lost Planet
Cancel

# Category Basics

It seems inevitable that, after one learned Haskell, there’s a good possibility she will become a victim of category theory. This is a series(hopefully) of notes about category theory. Category Th...

# A Simple REPL For the IMP Language

IMP is a simple imperative language described in the book The Formal Semantics of Programming Languages. The schema of the language is defined as follows: [\begin{align} a:=&n\mid X\mid a_0+a_...

# [LeetCode] 515. Find Largest Value in Each Tree Row

Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). Example 1: Input: root = [1,3,2,5,3,null,9] Output: [1,3,9] Example 2: ...

# [LeetCode] 226. Invert Binary Tree

Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired ...

# Difference Among WHNF, HNF and NF

Recently when I was reading the documentation of foldl' in the List module, I had some difficulty understanding the term Weak Head Normal Form. Here is the description of foldl', a strict version ...

# [LeetCode] 623. Add One Row to Tree

Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1. The adding rule is: given a positive ...

# [LeetCode] 565. Array Nesting

A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], … } subjected to the rule below. ...

# [LeetCode] 208. Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // ret...