Could not pass the test cases on submission :(

getting the correct answer on compile against the custom input, but getting the wrong answer on submission.

please help to figure out the bug.

My code:

please reply! It’s been 12 hrs.

Hey @swastikswarupmeher , Sorry for the delay my network was not working . Looking into your solution now .

Hey @swastikswarupmeher , the logi you are using is correct but you are changing the median inside the if and else condition itself . Also so much of conditions are not required . you only need to balance the heaps if the difference between them is 2 otherwise you just have to push it into one of the heaps .
Here is a more clear code to help you understand . I hope it helps !

Happy coding!
Mark your doubt as resolved if you have no further queries .

1 Like