Function to count number of mountains in a given matrix of size n
function countMountains ( a , n ) { var A = new Array ( n + 2 ) . fill ( 0 ) . map ( ( ) => new Array ( n + 2 ) . fill ( 0 ) ) ; var count = 0 ;