Only one test case is passing

Refer for the code: -