CVS Health interview question

Time complexity and space complexity of my code