I tried the assignment problem, but I am not getting all test cases passed, instead 4 test cases are passed and 4 are failed, can anyone help me with the code

Can you also put the question for the reference ?