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
|
2044 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
def pageCount(n, p): return min(p//2,n//2-p//2)
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
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) }
Here is my c++ solution, you can watch the explanation here : https://youtu.be/1T650YeAwRI
java(8)