Code correctly working on other IDE's but not a single test case passed here

code correctly working on other IDE’s but not a single test case passed here.
kindly take a look at my code. i don’t think it’s incorrect because code is fine on other ide’s. even the solution provided cannot pass the test cases.

for larger test case you ll get java.lang.NumberFormatException

this is because for Integer.parseInt(str); the maximum possible value of integer can be 127, but the value in the string is larger which is out of range, so this will throw the exception.

use

long val1int = new Long(val1);
long val2int = new Long(val2);

this will pass the test cases
please mark your doubt as resolved :slight_smile:

after changing int to long , only one test case has passed…

it passes all the test cases for me
just changed to new Long
check this


please mark your doubt as resolved if this works :slightly_smiling_face:
happy coding!