J.P. Morgan interview question

They asked 2 algorithm questions.