We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
could someone tell me what wrong with this code. I failing 13 cases, but when i ran with custom imput using failed test imput it passed.
publicstaticList<String>cavityMap(List<String>grid){// Write your code hereList<String>res=newArrayList<>();for(Stringstring:grid){res.add(findMax(string));}returnres;}publicstaticStringfindMax(Stringstr){intmax=0;Strings="";for(inti=0;i<str.length();i++){if(Character.getNumericValue(str.charAt(i))>max)max=Character.getNumericValue(str.charAt(i));}if(Character.getNumericValue(str.charAt(0))==max||Character.getNumericValue(str.charAt(str.length()-1))==max){s=str;}else{s=str.replaceFirst(String.valueOf(max),"X");}returns;}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
You are viewing a single comment's thread. Return to all comments →
could someone tell me what wrong with this code. I failing 13 cases, but when i ran with custom imput using failed test imput it passed.