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 hereif(p==1||p==n||(n%2==1&&p==n-1)){return0;}intres=0;if(n-p>n/2){// p is on first halfres=p/2;}else{// p is on second halfres=(n-p)/2;res=res==0?1:res;}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 →