The Explanation here doesn’t give any guidance on how did this logic come as solution. I understand on Leetcode this is a Medium question, and it wants one to not use division operation. the Brute force anyhow for this question has to be a O(n2) solution, which is not even given here. And the solution that is given doesn’t explain why is this solution provided. Also the line numbers mentioned in the Explanation are completely wrong. this is just 4th solution I am yet looking into. I haven’t paid this hefty to clean up this space.


I completely agree with you. I had to go over this solution multiple times trying to find a pattern but I could not. I thought I am stupid and cannot get it but it turns out that I am not the only one who complained about the solution.