Thứ Hai, 28 tháng 10, 2019

[Hackerrank] Solution of Drawing Book in JavaScript

[Hackerrank] Solution of Drawing Book in JavaScript
[Hackerrank] Solution of Drawing Book in JavaScript
[Hackerrank] Solution of Drawing Book in JavaScript
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);
}

post written by:

Related Posts