Passed test for 4, had to refactor to recursive solution just to get the pass