JPMorganChase interview question

Asked about dsa question with complexities