Sir, i passed 2 test cases but failed in other 2 test cases. please check my code

hello @chandreshmaurya
solve it in O(SUM) space, memory limit is tight for this problem