1980. Find Unique Binary String | 3 Ways

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

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

  • @gamerversez5372
    @gamerversez5372 Год назад +1

    I learnt multiple new concepts

  • @bachkhoahuynh9110
    @bachkhoahuynh9110 Год назад

    the last solution is called Cantor's Diagonal Argument.

  • @shaikrahaman8933
    @shaikrahaman8933 Год назад

    bro upload a video how to use codeforces effectively

  • @mrbeanfan7217
    @mrbeanfan7217 Год назад

    Why not just sort the strings according to their decimal value and return the first missing number

    • @bachkhoahuynh9110
      @bachkhoahuynh9110 Год назад

      It's not a fast solution:
      1. converting each number to decimal value costs O(n) time, so in total it costs O(n^2) time.
      2. sorting costs O(n.log(n)).
      3. finding the first missing number costs O(n)
      So the time complexity will be O(n^2)

    • @HarshaVardhan-fu9kv
      @HarshaVardhan-fu9kv Год назад

      Converting binay to decimal number is O(16) only as max length is 16

    • @bachkhoahuynh9110
      @bachkhoahuynh9110 Год назад

      ​@@HarshaVardhan-fu9kv I'm done, after reading your comment I don't know what to say. Similarly, by using selection sort, at each step we just need to iterate through at most 16 elements, so the sorting step costs O(n). The total complexity reduces to O(n), that's so amazing. Just go back to your university and re-enroll in the Complexity Analysis class to learn Complexity Analysis on ALGORITHM, not on ALGORITHM WITH BOUNDED INPUT