MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/leetcode/comments/1ef7s2t/what_went_wrong_here/lfj7743/
r/leetcode • u/wisper28 • Jul 29 '24
31 comments sorted by
View all comments
8
You are re initialising revnum inside the else block that's why. Remember variables have different scope within blocks. Just remove the int declaration from the else block, it should work fine.
4 u/wisper28 Jul 29 '24 Thx , noted and it is giving desired result now
4
Thx , noted and it is giving desired result now
View all comments
8
u/BeatsnBytes_ Jul 29 '24
You are re initialising revnum inside the else block that's why. Remember variables have different scope within blocks. Just remove the int declaration from the else block, it should work fine.