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.
def pageCount(n, p):
# Calculate turns from front and back
front_turns = p // 2
back_turns = (n // 2) - (p // 2)
# Return the minimum of the two
return min(front_turns, back_turns)
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 →
Here's the solution in python: