Hackerrank – Cavity Map

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Filter all matrix indexes that are at the periphery. For all the rest choose one index and compare its value with all neighbours (left, right, up, down). If it is greater than all neighbours, replace it with 'X'.

I created solution in 4 languages:

All solutions are also available on my GitHub.

Scala

Java

JavaScript

Ruby