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).
		
			
				
	
	
		
			77 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Org Mode
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Org Mode
		
	
	
	
	
	
* Array and string manipulation
 | 
						|
** DONE Merging Meeting Times
 | 
						|
** DONE Reverse String in Place
 | 
						|
** DONE Reverse Words
 | 
						|
** DONE Merge Sorted Arrays
 | 
						|
** DONE Cafe Order Checker
 | 
						|
* Hashing and hash tables
 | 
						|
** DONE Inflight Entertainment
 | 
						|
** DONE Permutation Palindrome
 | 
						|
** DONE Word Cloud Data
 | 
						|
** DONE Top Scores
 | 
						|
* Greedy Algorithms
 | 
						|
** DONE Apple Stocks
 | 
						|
** DONE Highest Product of 3
 | 
						|
** DONE Product of All Other Numbers
 | 
						|
** DONE Cafe Order Checker
 | 
						|
** DONE In-Place Shuffle
 | 
						|
* Sorting, searching, and logarithms
 | 
						|
** DONE Find Rotation Point
 | 
						|
** TODO Find Repeat, Space Edition
 | 
						|
** DONE Top Scores
 | 
						|
** DONE Merging Meeting Times
 | 
						|
* Trees and graphs
 | 
						|
** DONE Balanced Binary Tree
 | 
						|
** DONE Binary Search Tree Checker
 | 
						|
** DONE 2nd Largest Item in a Binary Search Tree
 | 
						|
** TODO Graph Coloring
 | 
						|
** TODO MeshMessage
 | 
						|
** TODO Find Repeat, Space Edition BEAST MODE
 | 
						|
* Dynamic programming and recursion
 | 
						|
** TODO Recursive String Permutations
 | 
						|
** TODO Compute nth Fibonacci Number
 | 
						|
** TODO Making Change
 | 
						|
** TODO The Cake Thief
 | 
						|
** DONE Balanced Binary Tree
 | 
						|
** DONE Binary Search Tree Checker
 | 
						|
** DONE 2nd Largest Item in a Binary Search Tree
 | 
						|
* Queues and stacks
 | 
						|
** TODO Largest Stack
 | 
						|
** TODO Implement A Queue With Two Stacks
 | 
						|
** TODO Parenthesis Matching
 | 
						|
** TODO Bracket Validator
 | 
						|
* Linked lists
 | 
						|
** DONE Delete Node
 | 
						|
** TODO Does This Linked List Have A Cycle?
 | 
						|
** TODO Reverse A Linked List
 | 
						|
** TODO Kth to Last Node in a Singly-Linked List
 | 
						|
** TODO Find Repeat, Space Edition BEAST MODE
 | 
						|
* System design
 | 
						|
** TODO URL Shortener
 | 
						|
** TODO MillionGazillion
 | 
						|
** TODO Find Duplicate Files
 | 
						|
* General programming
 | 
						|
** TODO Rectangular Love
 | 
						|
** TODO Temperature Tracker
 | 
						|
* Bit manipulation
 | 
						|
** TODO Binary Numbers
 | 
						|
** TODO The Stolen Breakfast Drone
 | 
						|
* Combinatorics, probability, and other math
 | 
						|
** TODO Which Appears Twice
 | 
						|
** TODO Find in Ordered Set
 | 
						|
** DONE In-Place Shuffle
 | 
						|
** TODO Simulate 5-sided die
 | 
						|
** TODO Simulate 7-sided die
 | 
						|
** TODO Two Egg Problem
 | 
						|
* JavaScript
 | 
						|
** TODO JavaScript Scope
 | 
						|
** TODO What's Wrong with This JavaScript?
 | 
						|
* Coding interview tips
 | 
						|
** TODO How The Coding Interview Works
 | 
						|
** TODO General Coding Interview Advice
 | 
						|
** TODO Impostor Syndrome
 | 
						|
** TODO Why You Hit Dead Ends
 | 
						|
** TODO Tips for Getting Unstuck
 | 
						|
** TODO The 24 Hours Before Your Interview
 | 
						|
** TODO Beating Behavioral Questions
 | 
						|
** TODO Managing Your Interview Timeline
 |