Qualtrics Interview Question

What is the time and space complexity of your code