3213. Construct String with Minimum Cost | Weekly Leetcode 405

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

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

  • @dawodujohnson
    @dawodujohnson 4 месяца назад +3

    Favourite youtuber tbh
    I was really hoping you would post it
    Thanks!

  • @Cools74
    @Cools74 4 месяца назад

    39:50 If you change
    set word_lens to
    unordered_set word_lens
    It passes all testcases

    • @codingmohan
      @codingmohan  4 месяца назад +1

      Thanks!
      To clarify, It still fails with "set"?
      TBH, I was expecting something like this and it doesn't make sense to keep the TC this strict especially given other unoptimized solutions are passing.

    • @Cools74
      @Cools74 3 месяца назад +1

      Yes it fails using set I think it takes o(logn) time for insertion where in unordered set it takes o(1) time
      Anyways nice solution

  • @YeetYeetYe
    @YeetYeetYe 3 месяца назад

    Amazing explanations. Your channel is going to grow very big!

  • @sanjai_rs7
    @sanjai_rs7 4 месяца назад +1

    This is next level explanation💥

  • @3frenchomelettes
    @3frenchomelettes 3 месяца назад

    Thanks. I learned string hashing from this video. Kinda frustrating that it TLEs though. I noticed the O(n^2) dp solution then just stared at the problem for ~30 minutes thinking how to optimize before giving up. Kind of strange that even the top contest participants confidently submitted O(n^2) trie solutions. It's like they collectively thought: "yeah this should pass per Leetcode standards"
    edit: jerryxu20 (7th place) got AC with a hashing solution. He sorted the lengths and added a break condition if i + lengths[j] >= n. He also used bottom-up dp

  • @ujjwalagnihotri5001
    @ujjwalagnihotri5001 Месяц назад

    LeetCode problem setters are probably high. In most of string hashing questions unoptimized solutions passes and optimized one times out

  • @MrSaint-ch6xn
    @MrSaint-ch6xn 4 месяца назад

    You are awesome !! Just why i found your channel too late

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls 4 месяца назад

    learned something new thanks mohan

  • @priyanshkumar17
    @priyanshkumar17 4 месяца назад

    Thanks bhaiya. Was waiting for this video

  • @Cools74
    @Cools74 4 месяца назад +1

    Waited for this video 💥

  • @madhurmittal943
    @madhurmittal943 4 месяца назад

    Great buddy

  • @varungudamsetti449
    @varungudamsetti449 3 месяца назад

    Is it possible to find hashInRange by just dividing it by p powers without having to compute inversePpowers? Thank you.

    • @codingmohan
      @codingmohan  3 месяца назад

      You can't simply divide because the multiplication is already "mod M". Hence the number wouldn't be divisible if we use a normal division operator.

    • @varungudamsetti449
      @varungudamsetti449 3 месяца назад

      @@codingmohan is there any other way without having to find inversePpower? (Sorry if my question seems dumb)

    • @codingmohan
      @codingmohan  3 месяца назад

      Not really - because you are doing modular arithmetic.
      If you want to divide you need to ferment little' theorem here.

  • @Algorithmswithsubham
    @Algorithmswithsubham 3 месяца назад

    726. Number of Atoms ,please explain this question

  • @aaravarya4406
    @aaravarya4406 3 месяца назад

    Your trie solution is not clear, can you explain a bit more on that?

  • @tasniatahsin8637
    @tasniatahsin8637 2 месяца назад

    your solution gave worng ans, it is giving me -1