TikTok interview question

What is the time complexity? Can you use stack instead of recursion?