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 herestart_count=0end_count=0start=1end=n# From starti=1whilei<=end:ifi>=p:breaki=i+2start_count+=1# From endifend%2==0:j=endelse:j=end-1whilej>=start:ifj<=p:breakj=j-2end_count+=1returnmin(start_count,end_count)
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 →
Intuative using loop