UBS interview question

Algo and SQL coding challenge