File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed 
src/com/hackerrank/algorithms/implementation Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ package  com .hackerrank .algorithms .implementation ;
2+ 
3+ import  java .util .Scanner ;
4+ 
5+ /** 
6+  * Created by ramswaroop on 08/05/2016. 
7+  */ 
8+ public  class  CavityMap  {
9+     public  static  void  main (String [] args ) {
10+         Scanner  in  = new  Scanner (System .in );
11+         int  n  = in .nextInt ();
12+         String  grid [] = new  String [n ];
13+         for  (int  grid_i  = 0 ; grid_i  < n ; grid_i ++) {
14+             grid [grid_i ] = in .next ();
15+         }
16+         for  (int  i  = 1 ; i  < n  - 1 ; i ++) {
17+             for  (int  j  = 1 ; j  < n  - 1 ; j ++) {
18+                 if  (Character .getNumericValue (grid [i ].charAt (j )) > Character .getNumericValue (grid [i ].charAt (j  - 1 ))
19+                         && Character .getNumericValue (grid [i ].charAt (j )) > Character .getNumericValue (grid [i ].charAt (j  + 1 ))
20+                         && Character .getNumericValue (grid [i ].charAt (j )) > Character .getNumericValue (grid [i  - 1 ].charAt (j ))
21+                         && Character .getNumericValue (grid [i ].charAt (j )) > Character .getNumericValue (grid [i  + 1 ].charAt (j ))) {
22+                     grid [i ] = grid [i ].substring (0 , j ) + "X"  + grid [i ].substring (j  + 1 );
23+                 }
24+             }
25+         }
26+         for  (int  grid_i  = 0 ; grid_i  < n ; grid_i ++) {
27+             System .out .println (grid [grid_i ]);
28+         }
29+     }
30+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments