BACK-TO-BACK FOURTH PLACE Sub 15 Minute Performances? Leetcode Weekly Contest 300

Ғылым және технология

So, after the contest, it was pointed out to me that O(N^2) is sufficient for Q3. I forgot to look at the constraints, so i spent extra time working on a O(N) solution. Had I not been blind, I would've won :(
0:00 Introduction
0:19 Solving A
1:42 Solving B
3:56 Solving C
12:09 Solving D
14:36 Explaining A
15:32 Explaining B
16:59 Explaining C
20:04 Explaining D
#leetcode #coding #python

Пікірлер: 6

  • @chrisadams27
    @chrisadams272 жыл бұрын

    i believe it, you are the best man... kinda new to these, but i just love watching how you solve these, learning a lot. thank you for posting!!

  • @anonymoussloth6687
    @anonymoussloth66872 жыл бұрын

    Hi, i know this is a cliche question but can you explain how you knew immediately that q3 was dp? I thought it was like a prefix sum problem. I know practice is critical but for some reason, i still don't know how to approach new problems. Can you give any advice for this?

  • @siddu6003

    @siddu6003

    2 жыл бұрын

    Observe the patterns while you are solving practice questions.

  • @CSBAjay

    @CSBAjay

    2 жыл бұрын

    For dp implementation some memory is required , so check the constraints.. If constraints is showing something huge like 10**9 then the problem is not meant for dp coz it will exceed memory limit.... If constraint is small like 500, 1000 then it means we can use dp... For today's contest.. constraint is 1 < delay < forget < 1000.. so I thought I can use dp.. this is just one of my observation

  • @numb3r5

    @numb3r5

    2 жыл бұрын

    DP is often used when the answer for some value (the 'state') depends on the answers for previous values/states. In this case, the number of people hearing the secret on any given day depends on the number of people hearing the secret of previous days. So DP is likely to be appropriate.

  • @anonymoussloth6687

    @anonymoussloth6687

    2 жыл бұрын

    @@numb3r5 thanks! I now realize that looking at the constraints and the fact that the answer could be big so we need to mod it also hints that it is dp. It's just that even knowing it is dp is just the beginning. The main thing is to come up with the relation to the subproblems which i guess can only be improved with practice right?

Келесі