Ouput is correct every test case fails

Check now ->


no need of J variable it’s just consuming your memory. Recursive calls were not right have edited them