Created
October 28, 2019 09:59
-
-
Save daubattu/519e453c5dee02688ab96e49aa814287 to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Drawing Book in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pageCount(n, p) { | |
/* | |
* Write your code here. | |
*/ | |
const pageFromStart = Math.floor(p/2); | |
const pageFromEnd = Math.ceil(((n % 2 !== 0 ? n - 1 : n) - p)/2); | |
return Math.min(pageFromStart, pageFromEnd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment