Doubt regarding Hints

I am not able to clear the last two test cases of this question, could I get some hints as what might be lacking in my code.

use long looking at the constraints