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.
- Drawing Book
- Discussions
Drawing Book
Drawing Book
Sort by
recency
|
197 Discussions
|
Please Login in order to post a comment
My java soultion
Hi all, could I know the issue with my submission (Java)? It passes all cases but one.
The case it fails is n = 6, p = 5
function pageCount(n, p) { const fromS=Math.floor((p /2)); const extraPage=(n%2)?0:1 const fromE=Math.floor((n-p+extraPage) /2)
return fromE>fromS?fromS:fromE } JavaScript
JAVA
return(p/2>(n/2)-(p/2)?(n/2)-(p/2):p/2);
Java.