3213. Construct String with Minimum Cost | Weekly Leetcode 405

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 20

  • @Cools74
    @Cools74 5 місяців тому

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

    • @codingmohan
      @codingmohan  5 місяців тому +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 5 місяців тому +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

  • @dawodujohnson
    @dawodujohnson 5 місяців тому +3

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

  • @sanjai_rs7
    @sanjai_rs7 5 місяців тому +1

    This is next level explanation💥

  • @YeetYeetYe
    @YeetYeetYe 5 місяців тому

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

  • @Cools74
    @Cools74 5 місяців тому +1

    Waited for this video 💥

  • @3frenchomelettes
    @3frenchomelettes 5 місяців тому

    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

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls 5 місяців тому

    learned something new thanks mohan

  • @ujjwalagnihotri5001
    @ujjwalagnihotri5001 2 місяці тому

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

  • @madhurmittal943
    @madhurmittal943 5 місяців тому

    Great buddy

  • @priyanshkumar17
    @priyanshkumar17 5 місяців тому

    Thanks bhaiya. Was waiting for this video

  • @MrSaint-ch6xn
    @MrSaint-ch6xn 5 місяців тому

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

  • @varungudamsetti449
    @varungudamsetti449 5 місяців тому

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

    • @codingmohan
      @codingmohan  5 місяців тому

      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 5 місяців тому

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

    • @codingmohan
      @codingmohan  5 місяців тому

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

  • @Algorithmswithsubham
    @Algorithmswithsubham 5 місяців тому

    726. Number of Atoms ,please explain this question

  • @aaravarya4406
    @aaravarya4406 5 місяців тому

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

  • @tasniatahsin8637
    @tasniatahsin8637 3 місяці тому

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