• + 0 comments

    That's a good solution but in the for loop instead of for (int a=i;j>a; a++) you need to use for (int a=i;j>=a; a++) so that it also checks for the value of a itself and will return the correct and required output.In the case what you have done there might be wrong answer for some of the test cases. HOPE THIS HELPS!!!