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.
defpageCount(n,p):# Write your code hereif(n==1orn==p):return0if(n%2>0andp==n-1):return0midpage1,midpage2=int(n/2),int(n/2)+1page_counter=0if(p<=midpage1):start=1while(start<p):start+=2page_counter+=1elif(p>=midpage2):start=n-1if(start==p):return1while(start>p):start-=2page_counter+=1returnpage_counter
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 →