Lexicographical Numbers |String DSA in JAVA| Leetcode 386 in Java | MUST DO String QUESTIONS | MAANG

Поделиться
HTML-код
  • Опубликовано: 10 окт 2024

Комментарии • 9

  • @vinaypinjala6341
    @vinaypinjala6341 20 дней назад +2

    Came here from leetcode awesome explanation

  • @vinaypinjala6341
    @vinaypinjala6341 20 дней назад +2

    Thank You very much for clear explanation

    • @TheCodeThoughts
      @TheCodeThoughts  20 дней назад

      Thanks buddy, nice to hear that you liked it.

  • @dhaneshthakur6481
    @dhaneshthakur6481 17 дней назад

    All clear explanation

  • @kapilbaliyan3407
    @kapilbaliyan3407 19 дней назад

    Good sir

  • @WebDevAnjali
    @WebDevAnjali 19 дней назад

    a silly question using 'if' instead of 'while' works for the most test cases but fails at some why n how does while makes any difference?

    • @TheCodeThoughts
      @TheCodeThoughts  18 дней назад +1

      actually, it's a great question not silly, so consider n = 192, so if we use if() instead of while, after adding 192 to the list you will increase curr = 193 come to if()==> now here you will check if(193%10==9 || 193>=n) so you will make curr = 193/10 = 19 ==> 19+1 = 20====> so now due to if condition you missed to add value 2, because 2 is supposed to come before 20....
      but if you use while loop first you will make 193/10 = 19 and you will again check 19 ===> 19%10 == 9 so again you will make curr = curr/10 ==> 19/10 = 1 and then increase it 1+1 = 2 , now you will not miss value 2.

    • @WebDevAnjali
      @WebDevAnjali 13 дней назад

      @@TheCodeThoughts ah thank u so much great explanation, now I get it ❤️❤️🙏🏻🙏🏻