BNY interview question

Given some code and algorithms to identify their time complexity and space complexity. Followed by a medium-level coding question.