All Posts

1582 articles

dsa7 min read

Find the Length of the Longest Common Prefix — Digit Trie

LeetCode 3043 — find the longest common prefix length between any number in arr1 and any number in arr2 (compared as digit strings). A digit trie of arr1 makes each arr2 lookup O(D) where D is the number of digits.

Read →
dsa6 min read

Count Distinct Substrings — Suffix Trie Node Counting

Count the number of distinct substrings of a string. The elegant trick: every substring is a prefix of some suffix, so a suffix trie has exactly one node per distinct non-empty substring. Count nodes during insertion in O(N^2).

Read →
dsa5 min read

Tries — Master Recap and Interview Cheatsheet

Complete Tries cheatsheet for FAANG interviews: core operations, 5 patterns, binary trie for XOR, decision guide, complexity table, and problem index covering all 20 trie problems.

Read →
Page 177 of 317