Code seems right, still it is giving error

Code is running successfully but still test cases are not passing

Hi, Is anyone there?

Hey @kumarshammy11 The problem with your code is that for test case:
4 2
12 34 67 90
6 3
12 34 55 67 90 95
correct answer is :
113
157
but your code is printing :
113157
So instead of using System.out.print(res);
use System.out.println(res);
and all test cases will pass

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.