LeetCode 3 Longest Substring Without Repeating Characters | Blind 75 | Python | Sliding Window

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

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

  • @CodeInMotion-IO
    @CodeInMotion-IO  12 дней назад +1

    Hope this helps you understand the problem, happy hacking!

  • @rachitsharma7921
    @rachitsharma7921 10 дней назад

    A better approach is to use bit manipulation to set the value of passed character and xor the current one to check if current char exists or not in Constant space linear time complexity

    • @CodeInMotion-IO
      @CodeInMotion-IO  10 дней назад

      The bit approach is more complex than using a hashmap and starts breaking down if the values aren't guaranteed to be ASCII. In fact, one can argue the hashmap solution is O(1) because the problem states only english letters, digits, symbols, and spaces are used. Therefore, the hashmap has a constant upper bound of keys, even in the worst case.