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.
Same issue here, correct results are marked as failures:
importjava.io.*;importjava.util.*;importjava.text.*;importjava.math.*;importjava.util.regex.*;publicclassSolution{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);Strings=in.next();int[]gridSize=findMinimumArea(s.length());char[][]grid=newchar[gridSize[0]][gridSize[1]];intcursor=0;for(introw=0;row<gridSize[0];row++){for(intcol=0;col<gridSize[1];col++){if(cursor>=s.length()){break;}else{grid[row][col]=s.charAt(cursor);cursor++;}}}Stringans="";for(intcol=0;col<gridSize[1];col++){for(introw=0;row<gridSize[0];row++){ans+=grid[row][col];}ans+=" ";}System.out.println(ans.trim());}// [rows, cols]privatestaticint[]findMinimumArea(intn){intmin=(int)Math.round(Math.floor(Math.sqrt(n)));intmax=(int)Math.ceil(Math.sqrt(n));for(introw=min;row<=max;row++){for(intcol=row;col<=max;col++){if(row*col>=n){returnnewint[]{row,col};}}}thrownewError("shouldn't get here : "+n);}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
Same issue here, correct results are marked as failures: