Why same solution in java takes more time to execute than C++

my code is not accepting on geek for geeks online platform where as a same solution in C++ accepted as it was taking less time. how can we reduce the time taken in java. Is it due to Scanner class or any other reason.

Hi Shantanu

Try using BuffferReader. It reduces run time to some extent.