recursive way, large cases failed
dp, large cases passed
not in place, use stack