ByteDance interview question

Algorithm question was related to recursion