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.
I saw a lot of solutions here that are wrong. I do not know why the test cases do not catch it. One example where most of solutions will fail is for an input of 10 and 7. I hope the test cases are updated.
A complete correct solution.
importjava.io.*;importjava.util.*;importjava.text.*;importjava.math.*;importjava.util.regex.*;publicclassSolution{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);intn=in.nextInt();intp=in.nextInt();ints=p/2;intf=n%2==0?(n+1-p)/2:(n-p)/2;intb=s<f?s:f;System.out.println(b);// your code goes here}}
Cookie support is required to access HackerRank
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 →
I saw a lot of solutions here that are wrong. I do not know why the test cases do not catch it. One example where most of solutions will fail is for an input of 10 and 7. I hope the test cases are updated.
A complete correct solution.