I have this function and I am trying to calculate time and space complexity, I got an answer but I am not sure if it\'s correct, I\'d like to know whether this is correct or