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.
publicstaticintpageCount(intn,intp){// Write your code hereintstartTurns=-1;for(inti=1;i<=n;i+=2){startTurns++;if(i>=p){break;}}intendTurns=-1;for(inti=n;i>=0;i-=2){endTurns++;if(n%2==0&&i<=p){break;}elseif(n%2==1&&i<=p+1){break;}}return(startTurns>endTurns)?endTurns:startTurns;}
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 →