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.
- Prepare
- Algorithms
- Implementation
- Drawing Book
- Discussions
Drawing Book
Drawing Book
Sort by
recency
|
2013 Discussions
|
Please Login in order to post a comment
Please suggest for optimization
def pageCount(n, p): no_front = p//2 if n % 2 ==0: no_back = (n-p+1)//2 else: no_back = (n-p)//2
Java Simple Answer return Math.min(p/2, (n/2 -p/2));
Java Simple Code /* Saving page no as key in hashMap, value as pages turns(steps) pageNo steps 0 0 1 0
Java Simple Code import java.util.*;
public class DrawingBookPages { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //no of pages in book int p = sc.nextInt(); // page to turn to
}
Hi! Here's my Java solution for the challenge. If anyone wants to chat about programming or other topics, feel free to reach out!
https://github.com/eduardocintra/hacker-rank-solutions/blob/master/src/br/com/eduardocintra/easy/drawingbook/DrawingBook.java