You are viewing a single comment's thread. Return to all comments →
TS SOLUTION:
function pageCount(n: number, p: number): number { // Write your code here const leftFlips: number = Math.floor(p / 2) const rightFlips: number = Math.ceil(((n - n % 2) - p) / 2) return Math.min(leftFlips, rightFlips) }
Seems like cookies are disabled on this browser, please enable them to open this website
Drawing Book
You are viewing a single comment's thread. Return to all comments →
TS SOLUTION:
function pageCount(n: number, p: number): number { // Write your code here const leftFlips: number = Math.floor(p / 2) const rightFlips: number = Math.ceil(((n - n % 2) - p) / 2) return Math.min(leftFlips, rightFlips) }