319652fe08
Return a function that returns the second largest item in a binary search tree (i.e. BST). A BST is a tree where each node has no more than two children (i.e. one left child and one right child). All of the values in a BST's left subtree must be less than the value of the root node; all of the values in a BST's right subtree must be greater than the value of the root node; both left and right subtrees must also be BSTs themselves. I solved this problem thrice -- improving the performance profile each time. The final solution has a runtime complexity of O(n) and a spacetime complexity of O(1).
2.2 KiB
2.2 KiB
- Array and string manipulation
- Hashing and hash tables
- Greedy Algorithms
- Sorting, searching, and logarithms
- Trees and graphs
- Dynamic programming and recursion
- Queues and stacks
- Linked lists
- System design
- General programming
- Bit manipulation
- Combinatorics, probability, and other math
- JavaScript
- Coding interview tips