correct (albeit innefficient) implementation of optimal bst
correct recursive & iterative for all testcases, but not for Q2
fixed off-by-one error to get correct ans for Q2