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.
- Drawing Book
- Discussions
Drawing Book
Drawing Book
Sort by
recency
|
201 Discussions
|
Please Login in order to post a comment
Scala (simple):
Python3 solution:
C++
public static int pageCount(int n, int p) { /* If the last page is Even, It will be on left or right side of the page, But to reach the page p from first page, if we divide it by 2 , we will get the number of pages we have to turn as every page contains two pages. / int firstpagePath = p/2; / From the last page if we divide number of pages n by 2, we will get how many pages, we have to turn to get to the last page. So, Basically it will take n/2-p/2 pages to get to the page p from the last page
My java soultion