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.
A new test case must have been added or I glitched. What I did to fix it.
publicclassSolution{staticintsolve(intn,intp){inthalfway=n/2;intturns=0;if(p>halfway){// turn from backintrev=n-p;if(rev>1){turns=rev/2;}elseif(n%2==0&&rev==1){turns=1;}}else{// turn from frontif(p>1){turns=p/2;}}returnturns;}publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);intn=in.nextInt();intp=in.nextInt();intresult=solve(n,p);System.out.println(result);}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Drawing Book
You are viewing a single comment's thread. Return to all comments →
A new test case must have been added or I glitched. What I did to fix it.