Pergunta de entrevista da empresa BNY

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