J.P. Morgan interview question

4 algorithms to write and 4 sql queries to write.