Solved #39 in scala
Solved #22 in scala