I can’t understand why my code is failing for the last testcase. Please help.
Link to my submission: CodeChef: Practical coding for everyone
I can’t understand why my code is failing for the last testcase. Please help.
Link to my submission: CodeChef: Practical coding for everyone
One of the test cases that your code fails is :-
1
3 7
Expected - 9
Your answer - 10
Fix:-
Change
if(str.length() == 1) return (str[0] - '0') + k;
To
if(str.length() == 1) return min(9ll, (str[0] - '0') + k);
Thanks a lot