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

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 8

  • @allaboutthementality1594
    @allaboutthementality1594 Před 2 lety +1

    amazing explanation, extremely simple to understand! TY!

  • @iitgupta2010
    @iitgupta2010 Před 29 dny

    Wonderful

  • @noguy5834
    @noguy5834 Před rokem

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

  • @MdMainuddinJU
    @MdMainuddinJU Před 2 lety +1

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

    • @kathmandu13
      @kathmandu13 Před 2 lety +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.

  • @user-py9om8zn9d
    @user-py9om8zn9d Před 2 lety +1

    This hlep me a lot, thank you!