The code explained by Monu Sir is not accepted on the Leetcode for input 2. On Leetcode, answer expected is 2 but as per the code explained by Monu Sir the output is 1.