The test case (10, 20 30, 40) yields the expected result 4 just fine when it is the only test case. However, when (10,20,30,40) is one among the ten test cases provided in the question, it gives an incorrect answer of 3.
Please find attached:
- code link to codingblocks ide:
- link to download the ten test cases: