dsa2 min read
Fraction to Recurring Decimal — Remainder Tracking HashMap
Convert a fraction to decimal string with recurring part detected via remainder position tracking.
Read →
1575 articles
Convert a fraction to decimal string with recurring part detected via remainder position tracking.
Find all duplicate subtrees by serializing each subtree and tracking serialization counts in a hash map.
Implement a hash map from scratch using an array of buckets with chaining for collision resolution.
Implement a hash set from scratch supporting add, remove, and contains in O(1) average time.
Pick a random index of a target value with equal probability using reservoir sampling over the array.