Quantexa Interview Question

Scala coding question