LeetCode is a JOKE with This ONE WEIRD TRICK

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 100

  • @algo.monster
    @algo.monster  ปีที่แล้ว +8

    Full constraint to algo mapping and code examples here: algo.monster/problems/runtime_summary

  • @ohmegatech666
    @ohmegatech666 8 หลายเดือนก่อน +158

    This is a pretty genius way to start approaching algo problems because it's way easier to look at constraints to determine the required time complexity than it is to look at the problem description and determine what algorithms or data structures fit

    • @algo.monster
      @algo.monster  8 หลายเดือนก่อน +5

      Thanks! Yes, it is, indeed!

  • @TheRn35
    @TheRn35 ปีที่แล้ว +144

    Goodhart's Law is expressed as: “When a measure becomes a target, it ceases to be a good measure.”
    But, I guess, it is what it is.

    • @algo.monster
      @algo.monster  ปีที่แล้ว +31

      hahaha, yes indeed. LeetCode-style interviews is just a game we have to play to get in the door.

  • @RJ-ko3ln
    @RJ-ko3ln 2 หลายเดือนก่อน +201

    You guys didn’t know this ??

    • @sadboy-xx6gh
      @sadboy-xx6gh 2 หลายเดือนก่อน +70

      Well if you knew, you wouldnt be watching this video now, would you?

    • @rahulbasetti700
      @rahulbasetti700 2 หลายเดือนก่อน

      😂😂😂😂😂😂😂​@@sadboy-xx6gh

    • @yagnikbose8973
      @yagnikbose8973 2 หลายเดือนก่อน +5

      ​@@sadboy-xx6ghha got 'em!

    • @mr.rabbit5642
      @mr.rabbit5642 2 หลายเดือนก่อน

      ​@@sadboy-xx6gh obviously. We also never buy a kinder surprise eggs with a toy we already have!
      Fr tho, people getting IT jobs should know this from a fucking college, among other fundamentals. Not as a 'crazy hack' for code monkeys to ace leet code...

    • @pushkarroy9740
      @pushkarroy9740 2 หลายเดือนก่อน +13

      Yeah how can you not see the pattern of time limit exceed and constraint

  • @raghavbagdi87
    @raghavbagdi87 4 หลายเดือนก่อน +43

    Damnnnnn, this is soooooo underrated man. Love such insights! Keep em coming

    • @algo.monster
      @algo.monster  4 หลายเดือนก่อน +2

      Glad it helps! And Zlatan is the best haha

  • @shklbor
    @shklbor หลายเดือนก่อน +4

    in an actual interview even the interviewer might not know the correct input size, and wrong assumptions/guesswork will give you a much more lenient (smaller) input size leading to a more suboptimal approach than the interviewer is expecting (e.g. quadratic instead of linear)

    • @algo.monster
      @algo.monster  หลายเดือนก่อน +2

      Why not ask for the constraint? Constraint is part of the problem definition, without which a problem is not complete. And requirement gathering is a key skill for engineers and something interviewer would want to evaluate on.

  • @algo.monster
    @algo.monster  หลายเดือนก่อน +1

    This is a common question so want to make a special note here:
    - In an online coding assessment, you can obviously use this technique.
    - In an in-person interview, you should always ask for the constraints up front , as they are a part of the problem definition. The difference between n=10 and n=10,000 can entirely changes the problem. And requirement gathering is a key part of an engineer's skill set. Also make sure you know how to use the patterns: th-cam.com/video/RYT08CaYq6A/w-d-xo.html

  • @1234victorxD
    @1234victorxD 5 หลายเดือนก่อน +21

    Dude that was really smart wtf

  • @HusnaKhanam-bm4fq
    @HusnaKhanam-bm4fq 9 หลายเดือนก่อน +2

    was much needed !!!!

  • @umeshhbhat
    @umeshhbhat 2 หลายเดือนก่อน +12

    But the issue with this approach is that in the onsite interview, interviewer won't tell you the constraints. You need to find out the most optimal approach based on the problem description not the constraints.

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน +11

      You can always ask for constraints. Clarifying requirement and effective communication is a key aspect of software engineer's skill set.

    • @umeshhbhat
      @umeshhbhat 2 หลายเดือนก่อน +5

      Interviewer would mostly probably say let's not worry about the input size, let's try to come up with optimal solution.

    • @FM1234
      @FM1234 หลายเดือนก่อน +2

      Well usually you practice enough that it simply does not matter. Also, at a certain point you use the constraints not so much as a guide, but as a what do they want here? Like, are they forcing me to work for the solution or is this an easy problem that let's me implement some other worse version.
      For example, longest common substring's dp vs suffix stuff solution (e.g. suffix array)

  • @KuaisArts
    @KuaisArts ปีที่แล้ว +5

    It's hard coming up with what specific class of algorithms I should use :( This way is definitely useful if you ask for constraints!

  • @i_youtube_
    @i_youtube_ 2 หลายเดือนก่อน +3

    I want to understand how code is executed and how does LeetCode measure the best solutions? Anybody can list some technical concepts I need to learn?

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน +1

      Check out this video on how leetcode works behind the scene: th-cam.com/video/hRnJxPeoZyg/w-d-xo.html

  • @SAIKRISHNADANDU
    @SAIKRISHNADANDU 9 หลายเดือนก่อน

    Found best one❤

  • @funnyhilarious123
    @funnyhilarious123 2 หลายเดือนก่อน +1

    Hey, can you make something where more of these constraints or the inputs/language hints us to use specific algorithms, like if its asked minimize the maximum sum, we use binary search or something same like that???

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน +1

      Hey yes, we have a full flowchart on how to determining what algo to use: algo.monster/flowchart

  • @Rudra0x01
    @Rudra0x01 10 หลายเดือนก่อน

    Very informative

  • @takeuchi5760
    @takeuchi5760 2 หลายเดือนก่อน +1

    Yeah noticed this around when I had solved 70 questions.

  • @EverAfterBreak2
    @EverAfterBreak2 หลายเดือนก่อน

    Do you guys ask input size constraints in interviews?

  • @999fini
    @999fini หลายเดือนก่อน

    incredible insight, thank you

    • @algo.monster
      @algo.monster  หลายเดือนก่อน +1

      Glad it was helpful!

  • @Sridevikrish21
    @Sridevikrish21 6 หลายเดือนก่อน +4

    If the constraints is 5 *10^4
    Using this constraints which time complexity is used and in which approach we have to code

    • @yousafsabir7
      @yousafsabir7 4 หลายเดือนก่อน +1

      Apparently 5*10^4 falls under O(n) or O(nLogn) category

    • @wumi2419
      @wumi2419 2 หลายเดือนก่อน

      In video he states that you hit TLE at around 10^7 operations. So anything faster than O(n^1.5), that is O(n) and O(n log n).

  • @nbansal
    @nbansal 2 หลายเดือนก่อน +11

    What's the point of this. You are not solving LeetCode problem to game their system. You are trying to prepare for the interviews mostly or at least I am. So even though the platform accepts quadratic or even exponential solution, what's the point of it. Interviewer will obviously expect a better solution.

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน +10

      To quote the classic math book "How to Solve It" by George Pólya:
      "The conditions of the problem contain the essential data. If you analyze the conditions carefully, they will suggest the way to the solution."
      This is exactly how you are supposed to solve a problem - using whatever information you have in the problem description. This is not gaming the system. You need this knowledge to deduce what to do next. A reasonable interviewer will understand this. If not, you probably don't want that job anyways cuz they are probably not good engineers or collegues.
      Also LeetCode is usually stricter than real interviews. If you can solve it to pass LeetCode, you can pass the interview.

    • @geekofia
      @geekofia 2 หลายเดือนก่อน

      Interview deke kya kr lega ?

    • @FM1234
      @FM1234 หลายเดือนก่อน

      The difficulty already biases you though, I'm sure you look at that.

    • @bedro_0
      @bedro_0 หลายเดือนก่อน

      Gaming the system is the point for some people when it comes to interviewing

    • @RRunos
      @RRunos หลายเดือนก่อน

      @@algo.monster I understand what u mean, but this quote does not match the situation. The size of the data does not determine the most optimal solution. The runtime limit is something set by the coding platform and is not applicable to every interview (especially not applicable to industry or academia). TLE might not even exist as long as you don’t run out of memory. This only applies to Leetcode and similar coding platforms. They won’t always give you a runtime limit in interviews. Some companies also won’t give you any constraints or a TLE, they’ll just analyze how you handle unknown bounds and scenarios while still keeping an optimal algorithm. This is also bad practice for learning algorithms and data structures if you want to get into academia or actually build larger systems at work. This is only a good “hint” if u’r a beginner to leetcode.

  • @amartyadandapat9366
    @amartyadandapat9366 2 หลายเดือนก่อน

    This video is a GEM.

  • @Emmap11
    @Emmap11 ปีที่แล้ว

    Great video!!!

    • @algo.monster
      @algo.monster  ปีที่แล้ว

      Thanks! Glad you liked it!

  • @LAFLAME1111
    @LAFLAME1111 2 หลายเดือนก่อน +3

    I always did wonder how to interpret the size constraint, thanks for the helpful video and cheatsheet

  • @milkandhenny
    @milkandhenny ปีที่แล้ว +1

    Thanks!

  • @user-dz6zd9zk2f
    @user-dz6zd9zk2f หลายเดือนก่อน

    That's a very useful way of solving problems in OAs and CP challenges but in an interview, you cannot rely on this trick. A lot of the times, the interviewer will not mention a specific constraint and would ask you to come up with as many solutions as you can. Starting from the bruteforce to as optimal as it gets. Therefore it is more important to learn problem patterns, you should only come to the constraint part when you're confused between two approaches.

    • @algo.monster
      @algo.monster  หลายเดือนก่อน +1

      You should always ask for the constraints upfront as it's part of the problem definition in an in-person interview. Having n=10 vs n=10000 completely changes the problem. It also demonstrate your communication skills since requirement gathering is a key skill for an engineer.

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 5 หลายเดือนก่อน

    NICE SUPER EXCELLENT MOTIVATED

  • @erickjhormanromero6905
    @erickjhormanromero6905 2 หลายเดือนก่อน

    Yeah. That's really good.

  • @dennis3648
    @dennis3648 2 หลายเดือนก่อน +3

    I'm sitting here, watching AI generated content

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน

      haha, using voice clone cuz it's easier to sync the audio with video. the content is all original

  • @FM1234
    @FM1234 หลายเดือนก่อน +2

    This is the first thing you do in a problem. What if a problem is easy because of input size and you're optimizing nothing, that's just premature optimization. For example, if you have a dataset of 100 rows and you need to implement some algo which is naively N^2 but you spend useless time making it O(N) and more complex, in any case that's a bad idea.
    Leetcode says a problem is easy/med/hard and that just shifts your thinking.

    • @algo.monster
      @algo.monster  หลายเดือนก่อน

      Exactly! Engineering is all about gathering requirement and creating a solution for that requirement.

  • @Harshit-ju2iz
    @Harshit-ju2iz 2 หลายเดือนก่อน

    This is HUGE!!!!!!!

  • @immrhrr
    @immrhrr 4 หลายเดือนก่อน

    Nice❤

  • @sarthakbehera8324
    @sarthakbehera8324 2 หลายเดือนก่อน

    bele bele ta constraints guda deinathae anya online coding platform re. setebele tike sahibaku pade aau. aau interview re ta semane kuhantini. pacharile hi kahibe nale kahibe nahi kichhi constraints. seithi fasi jiba. jie true coder sei karipariba.

  • @farpurple
    @farpurple หลายเดือนก่อน

    I like how math is last resort

  • @thepathakarpit
    @thepathakarpit 2 หลายเดือนก่อน +5

    Thank you for teaching the first concept you need to learn before starting Competitive Programming but people are so dumb they don't pay attention to even that one

    • @FM1234
      @FM1234 หลายเดือนก่อน

      True

  • @pranavsharma7479
    @pranavsharma7479 หลายเดือนก่อน

    For 10^8 inputs ? O(n) ?

    • @harshkant8217
      @harshkant8217 หลายเดือนก่อน

      O(1) or O(logN)

  • @allentsai1982
    @allentsai1982 ปีที่แล้ว

    thx alot

  • @wasd3108
    @wasd3108 ปีที่แล้ว +1

    well that whale should have a full on clown costume and makeup. Because wherever the code is being tested at, the results are a joke XD

  • @s8x.
    @s8x. 5 หลายเดือนก่อน +1

    genius

    • @algo.monster
      @algo.monster  5 หลายเดือนก่อน

      Glad it helps!

  • @pamelapang9913
    @pamelapang9913 ปีที่แล้ว +2

    👍👍👍

  • @sharthakghosh970
    @sharthakghosh970 2 หลายเดือนก่อน +1

    This doesn't work all the time, cause there is a statistical aspect too that's taken into consideration. If more and more submissions are in O(n) rather than O(nlogn), your submission will be declined even if it was accepted before.

    • @fakenullie
      @fakenullie 2 หลายเดือนก่อน

      It doesn't work this way, but there's a probalistic element (I guess it depends on runner to which your submission is assigned and its load). So sometimes you can try to resubmit the same solution to pass

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน

      I don't think that's how it works. Timing is not dynamic adjusted. Like @fakenullie said the same solution could have different runtime. It's not stable. This is from my friend who worked as ops for LeetCode.

    • @sharthakghosh970
      @sharthakghosh970 2 หลายเดือนก่อน

      @@algo.monster I faced this with a few questions. When I attempted to submit the same code two years later it just kept failing. Also problems also change from hard to medium. I was watching some video by neet ode, where in the video it was hard but the problem in the site was a medium. I presumed that as acceptances increased, it changed

  • @48_subhambanerjee22
    @48_subhambanerjee22 2 หลายเดือนก่อน +1

    Love from india

  • @scott5227
    @scott5227 2 หลายเดือนก่อน

    These are basic things.

  • @kavascgjmd5790
    @kavascgjmd5790 2 หลายเดือนก่อน

    i thought u will go to inspect element change the constraints or test case something so that anything might work

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน

      User-submitted code is run on the server so it wouldn't work. But I like the way you think!! haha

  • @gmoney_swag1274
    @gmoney_swag1274 หลายเดือนก่อน

    Why is there an AI voice over?

    • @algo.monster
      @algo.monster  หลายเดือนก่อน

      It's my cloned voice, which makes syncing with the animation easier. This was one of our earlier videos, and we were still learning, so the quality isn't the best haha. Thanks for sticking with it anyway!

  • @kushiksahu1983
    @kushiksahu1983 หลายเดือนก่อน

    But in some cases due to this we overthink to optimise the time complexity. I think this fails and make us overthink specially in case of O(N) ARMOTISED complexity

    • @pile_of_kyle
      @pile_of_kyle หลายเดือนก่อน

      The point is that you can use the constraints to rule out runtimes that couldn't possibly be accepted by Leetcode.
      For example, if the input size is up to 1 million, you can instantly rule out any strategy that is as slow or slower than O(n^2), such as a 2D dynamic programming approach.

  • @dough-pizza
    @dough-pizza 2 หลายเดือนก่อน

    I dont think the aim is to just pass the leet code question. Typically if you use brute force in an interview the interviewer would just ask you "is there any other way to solve this?" And if brute force is all that you did its not going to end well

    • @algo.monster
      @algo.monster  2 หลายเดือนก่อน

      which is why you need to ask the constraint? a big part of an engineer's job is choosing the right tool for the right job.

  • @algo.monster
    @algo.monster  2 หลายเดือนก่อน

    Check this video to understand how LeetCode (or Hackerrank etc) works behind the scene: th-cam.com/video/hRnJxPeoZyg/w-d-xo.html

  • @zerrickb58
    @zerrickb58 6 หลายเดือนก่อน +1

    nerd

    • @ungabungalunga1002
      @ungabungalunga1002 2 หลายเดือนก่อน

      You think you're pretty cool don't you

  • @SuperMaDBrothers
    @SuperMaDBrothers ปีที่แล้ว +4

    This is true, but useless.

    • @algo.monster
      @algo.monster  ปีที่แล้ว +1

      can you elaborate? figuring out the algo is half the battle

    • @patrickbateman3912
      @patrickbateman3912 ปีที่แล้ว +2

      this is absolutely useful. not fully but looking at the constraints your 1/4th work is done

    • @automata-mw2el
      @automata-mw2el ปีที่แล้ว

      it's literally a binary search technique for the algorithm matching