dsa2 min read
Smallest String Starting From Leaf
Find lexicographically smallest string from any leaf to root by collecting and comparing reversed paths.
Read →
1575 articles
Find lexicographically smallest string from any leaf to root by collecting and comparing reversed paths.
Find time for infection to spread through entire tree from a start node by converting to graph then doing BFS.
Find minimum swaps to sort each level of a binary tree using BFS and cycle-detection in permutation sorting.
Implement an in-order BST iterator with O(h) space using a stack to simulate recursive in-order traversal.
Sum all root-to-leaf path sums in a tree encoded as 3-digit integers using a hashmap to decode tree structure.