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 hereintfrontMin=0;intbackMin=0;for(inti=1;i<=n;i++){if(i==p){frontMin=i/2;}}intcount=0;if(n%2==0){count=1;}for(inti=n;i>=1;i--){if(i==p){backMin=((count)/2);}count++;}intres=Math.min(frontMin,backMin);returnres;}
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 →