-
Notifications
You must be signed in to change notification settings - Fork 858
Expand file tree
/
Copy pathDrawingBook.java
More file actions
34 lines (27 loc) · 863 Bytes
/
Copy pathDrawingBook.java
File metadata and controls
34 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
*
* Problem Statement-
* [Drawing Book](https://www.hackerrank.com/challenges/drawing-book/problem)
* [Tutorial](https://youtu.be/aM2Y2PeXrhk)
*/
package com.javaaid.hackerrank.solutions.generalprogramming.basicprogramming;
import java.util.Scanner;
/**
* @author Kanahaiya Gupta
*
*/
public class DrawingBook {
static int pageCount(int n, int p) {
int totalPageTurnCountFromFront = n / 2;
int targetPageTurnCountFromFront = p / 2;
int targetPageTurnCountFromBack = totalPageTurnCountFromFront - targetPageTurnCountFromFront;
return Math.min(targetPageTurnCountFromFront, targetPageTurnCountFromBack);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int p = in.nextInt();
System.out.println(pageCount(n, p));
in.close();
}
}