[Java] Leetcode 224. Basic Calculator [Stack & Queue #7]

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024

ความคิดเห็น • 8

  • @allaboutthementality1594
    @allaboutthementality1594 2 ปีที่แล้ว +1

    amazing explanation, extremely simple to understand! TY!

  • @iitgupta2010
    @iitgupta2010 หลายเดือนก่อน

    Wonderful

  • @noguy5834
    @noguy5834 ปีที่แล้ว

    and what would we have had to change if we had had multiplication and division operations? How would we have setted the priorities then?

  • @某梁-t6y
    @某梁-t6y 3 ปีที่แล้ว +1

    This hlep me a lot, thank you!

  • @MdMainuddinJU
    @MdMainuddinJU 2 ปีที่แล้ว +1

    The index-- is still confusing to me. Can you please explain the purpose of it again? Thank you.

    • @kathmandu13
      @kathmandu13 2 ปีที่แล้ว +4

      The line number 30 increments index by 1. After increasing the index, if the index is pointing to a non-digit character, the while loop terminates. Remember though our index is now pointing to one of ()+- char. If we don't decrease the index on line 32, we will skip processing those chars on the next iteration of outer while loop (line 16) because line 36 would have increased the index one more time. Hope this helps.