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.
Just the do mathematics & it's simple (Code in C# )-
public static int pageCount(int n, int p)
{
int shortestRoute = 0;
if(n/2 < p){
//Start from back side
if(n%2 != 0){
shortestRoute = (int)(n-p)/2;
}else{
shortestRoute = (int)((n-p)+1)/2;
}
}
else{
//Start from biggining
shortestRoute = (int)p/2;
}
return shortestRoute;
}
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 →
Just the do mathematics & it's simple (Code in C# )-