Exploring LeetCode's WORST Questions

Sdílet
Vložit
  • čas přidán 6. 09. 2024

Komentáře • 62

  • @alperkaya8919
    @alperkaya8919 Před 2 lety +24

    I spent 7 hours without giving a break on "Recover a Tree From Preorder Traversal". But I've solved it at the end. My code was over 100 lines, and I even had to force a hashmap to handle duplicate keys. But it was worth it at the end, and it was my first hard question I've solved. So, one hour on a hard question is nothing in my opinion.

  • @danielgysi5729
    @danielgysi5729 Před 2 lety +24

    Controversial, but I honestly think a lookup table is a totally valid solution to the first problem and I think having an interview question like that is really valuable. Sometimes there just isn't a clever math trick that makes your program 100x faster. In the real world you need to compromise sometimes and saying "We never expect to receive input greater than n so precomputing f(x) for all x

    • @30svich
      @30svich Před 2 lety +8

      but there is actually a math trick, and he explains in the video someone solved this problem mathematically as it should be. it is not a bad problem, just people did not want to get involved with math.

  • @programmer9660
    @programmer9660 Před 2 lety +4

    Colin I love that you’re thinking out loud, keep doing that. Cheers

  • @rupok9999
    @rupok9999 Před 2 lety +6

    how about Codeforces Round #815 (Div. 2) today ?

  • @kennethkath6527
    @kennethkath6527 Před 2 lety +26

    Hey Colin, how are you so good at this? Takes me forever to solve even one question

  • @user-he4st2ro5h
    @user-he4st2ro5h Před 2 lety +6

    Hey Colin, I had a failed attempt to pass an online assessment for Amazon SDE position, and one of the tasks was leetcode # 2281, which is in top 15 with the least acceptance rate. Could you solve and explain it, please?

  • @Matthew4770
    @Matthew4770 Před 2 lety +2

    You updated your browser! So proud of you!

  • @wesleyso0
    @wesleyso0 Před 2 lety +5

    Amazing! Thanks for putting in all the hard work into making these videos! I hope I can be as good of an explainer as you are!

  • @fiveCSGO
    @fiveCSGO Před 2 lety +6

    how many years have you been programming in total?

  • @bufdud4
    @bufdud4 Před 2 lety +60

    I wonder if your employer would be more impressed to see you solve a difficult problem in less than said minutes versus communicating which would usually take 3x or 5x longer.

    • @anon3501
      @anon3501 Před 2 lety +4

      Communication is more important. This guy is wasting his time at this point, industry experience is more valuable then solving LC quickly lol

    • @FinnBender
      @FinnBender Před 2 lety +36

      @@anon3501 I mean he (probably) does this for his and our entertainment... Calling it "wasting time" seems a little harsh.

    • @anon3501
      @anon3501 Před 2 lety +1

      @@FinnBender true, i was just suggesting to build or work on something with his skills versus solving problems that add no value to the world

    • @vishnuvs6121
      @vishnuvs6121 Před 2 lety +11

      What you are saying is correct, but he's not doing this for appearing in interviews. People do this stuff for the fun of it too, as a hobby.

    • @anon3501
      @anon3501 Před 2 lety

      @@vishnuvs6121 You shouldn't be taking pride just in things like leet code, its a fun puzzle game but it shouldn't be a major motivator for you. Programmers are solving problems for people or doing something of value for people over what they could be doing

  • @saharshluthra6492
    @saharshluthra6492 Před 2 lety +5

    Hi Colin,
    For the first problem, the result has to be a palindrome, and apart from n = 1, safe to assume that answer will contain even number of digits. Which means it will be always be divisible by 11. So you can put a condition for one of your numbers to be divisible by 11, only then look for second number possibilities, this will pass leetcodes' time limit.
    Edit: Just resumed the video and realized this is already covered :)

    • @MichaelSt
      @MichaelSt Před 2 lety

      Why would the answer have an even number of digits?

    • @saharshluthra6492
      @saharshluthra6492 Před 2 lety

      @@MichaelSt You're multiplying 2 n digit numbers, presumably starting off with 8 or 9 as their first digit. so something like (8 * 10^(n - 1) + something smaller) * (8 * 10^(n - 1) + something smaller). So 64 * 100^(n - 1) + something small. This is clearly even number of digits.

    • @MichaelSt
      @MichaelSt Před 2 lety

      @@saharshluthra6492 a lot of assumptions there, like the number starting with 8 or 9, and the something small not "overflowing" into the next digit.
      I mean you can convince yourself it doesn't happen for 1

    • @saharshluthra6492
      @saharshluthra6492 Před 2 lety

      @@MichaelSt The something small is < 10^(n - 1) and it physically cannot contribute to another digit. 9999 * 9999 has the same number of digits as 4000*4000. The only way to get another digit is 10^4 * 10^4 which is are both n + 1 digit numbers now.
      Even if you consider a completely random distribution of what you're going to get as a result of multiplication, which it's not, the probability of you not finding a palindrome is astronomically small, and it gets even smaller as n grows. The assumptions don't get weaker, they get even stronger for n > 8.
      Same goes for starting digits, as n grows, assuming completely random distribution, the chances that you find numbers starting with 999.... become even greater.

  • @kunzi_is_here
    @kunzi_is_here Před 2 lety +3

    Dude Q2 had to feel so good to complete

  • @michaelmoran9020
    @michaelmoran9020 Před 2 lety +1

    For the 3rd one I do not understand why that trivial solution is the answer. When I read it I thought that for two strings
    "abcefg"
    "abcxyz"
    that the answer would be 3, with the subsequences being efg and xyz?

    • @muddycalendar3292
      @muddycalendar3292 Před 2 lety +4

      The string itself is a subsequence, so if you have abc and abd, the longest subsequences will be abc and abd, and since the subsequences are different, they can’t be in both

    • @michaelmoran9020
      @michaelmoran9020 Před 2 lety

      @@muddycalendar3292 I'm trying to figure out what implicit condition i was applying to reach my version

  • @tedchirvasiu
    @tedchirvasiu Před 2 lety +2

    The thumbnail is back

  • @_sixtyfour
    @_sixtyfour Před 2 lety +2

    For 50k subs, you should speed run eating 50 donuts

  • @rohitpunetha9506
    @rohitpunetha9506 Před rokem

    Your Background music is very haunting😈
    Nice content though.

  • @akashkumarsahoosibun8191

    I do not know why by seeing your thumbnail I feel so good

  • @oxi2118
    @oxi2118 Před 2 lety +1

    I learn so much from just watching you code

  • @BODYBUILDERS_AGAINST_FEMINISM

    Cool videos man

  • @keerthivasan9548
    @keerthivasan9548 Před 2 lety

    Bro can you able to make a tutorial on union find operations on matrix

  • @Jasturtle
    @Jasturtle Před 2 lety +3

    The real solution to the first largest palindromic product is
    n = 2 + (987-2);
    Return n;
    Ez i don't get why so many dislikes

  • @HHJoshHH
    @HHJoshHH Před rokem

    Cool video man. Only 4 weeks into programming but…this is fun to watch and try to understand.
    I’m starting in Python but I feel like I should be coding in JS. I’ll be lucky if I ever get smart enough to get a UI/UX job let alone an actual web/app dev job. 😅

  • @freyappari
    @freyappari Před rokem

    I solved the first one fine,,,
    class Solution:
    def largestPalindrome(self, n: int) -> int:
    if n == 1:
    return 9
    max_num = 10 ** n - 1
    min_num = 10 ** (n - 1)
    for num in range(max_num, min_num - 1, -1):
    # Construct a palindrome by joining num with its reverse
    palindrome = int(str(num) + str(num)[::-1])
    # Check if this palindrome can be represented as the product of two n-digit integers
    for i in range(max_num, int(palindrome ** 0.5) - 1, -1):
    if palindrome % i == 0 and palindrome // i

  • @cwagnello
    @cwagnello Před rokem

    91 multiplied by a number with "n" digits of 9 is a palindrome but that doesn't help with the question

  • @xyphenius9942
    @xyphenius9942 Před 2 lety

    Why do you mostly use C++ ?

    • @MichaelSt
      @MichaelSt Před 2 lety

      Its efficiency is good for competitive programming

  • @gabrielabdul
    @gabrielabdul Před 2 lety +1

    We need more creativity with these thumbnails -- nice vid tho.

  • @MD-lw4kw
    @MD-lw4kw Před 2 lety

    Krita and bloons TD 6🔥

  • @kaitmob3847
    @kaitmob3847 Před rokem

    Its ironic how he is a competitive programmer but used someone else's code to find the questions

  • @decafbad5529
    @decafbad5529 Před 2 lety +1

    cute boymoder

  • @keerthivasan9548
    @keerthivasan9548 Před 2 lety

    Leetcode 862

  • @koi.3311
    @koi.3311 Před 2 měsíci

    ur so cute >_

  • @ciupanezubogdanel
    @ciupanezubogdanel Před 2 lety +4

    3 + years of competitive coding experience, and when this guy is looking for the highest palindrome number from a product...he iterates up from 1 to 1000...instead of down from 1000

    • @Splish_Splash
      @Splish_Splash Před 2 lety +15

      (high - i) * (high - j) means nothing to you?

    • @Daman1628
      @Daman1628 Před rokem

      @@Splish_Splash lol

  • @mdyousufgazi4030
    @mdyousufgazi4030 Před 2 lety

    💥💥💥💥💥💥

  • @bhanupratapsharma6158
    @bhanupratapsharma6158 Před 2 lety +2

    Your voice is not coming

  • @thetallesthobbithsaka3050

    You guys are spending 1 hour on hard questions, i though medium takes that much 👀