TikTok Interview Question

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