K-TH MISSING POSITIVE NUMBER | LEETCODE 1539 | PYTHON SOLUTION

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

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

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

    Splendid explanation.

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

    Thank you for making these videos. You are awesome!

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

    Your vids and explanation are elite. Super easy to understand code, intuition explanations are straightforward, and your no BS attitude is refreshing. Thanks to your vids I actually managed to ace my Meta phone interview and am using your explanations to help study for the full loop.
    If you find the time, could you cover Count and Say? That one has been KILLER to find a solution online not written by some crackhead mathematician or using var names that make sense. Thanks again for all you do!

  • @armankhondker
    @armankhondker 5 หลายเดือนก่อน +3

    how about the binary search solution? this doesn't take advantage of the fact that the array is sorted

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

      This is meant to be an easy questions for people new to LC. Binary Search solution is a bit tricky here and the linear scan is easier to understand for people just starting out with easy questions

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

      @@crackfaang fair enough, I just feel like Meta interviewers will expect binary search solution.

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

      @@armankhondker I agree. BST is what would be expected. Plus that'd make the question a medium. Also, this question is easy to understand in approach in BST but the final statement that actually returns the missing number isn't easy by any stretch. Most LC code will just put left + K but why it works has a lot of depth in it.

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

    It only needs a few lines of code and one simple while loop. You are over complicating this question. T:O(N) and S: O(1) def findKthPositive(self, arr: List[int], k: int) -> int:
    i,j, count=1,0,0
    while j

    • @kbplays980
      @kbplays980 29 วันที่ผ่านมา

      heres a an even simpler version:
      for i in range(len(arr)):
      if(k < l[arr]):
      break
      k += 1
      return k

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

    Hey Thanks for the explanation!
    How do you get to know this question was asked in facebook?

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

      Leetcode premium gives you a list of questions asked by a company recently. It's user submitted based on their interviews but for Meta it's basically spot on

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

    Amazing explanation

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

    I think, i have a simpler version:
    def findKthPositive(arr: List[int], k: int) -> int:
    arr = set(arr)
    max_num = max(arr)
    not_found = []
    for i in range(1, max_num+1):
    if i not in arr:
    not_found.append(i)
    print(not_found)
    if len(not_found) >= k:
    return not_found[k-1]
    else:
    return max_num + (k - len(not_found))

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

    Can you solve the top Tiktok Question? Optimal Account Balancing

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

    Did you ever finish a coding interview early because you knew the answers to the questions already? Just eondering if that ever happens

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

      Yea all the time. But you are expected to be fast. You have 20 minutes per question so you need to train yourself to be fast. You end up just asking the interviewer some questions or using the time to go to the bathroom/mental break

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

    is there any reason binary search wasn't used?

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

      It''s meant to be an easy question for people new to LC. Doing it with binary search would be overkill for someone new

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

    This solution will not be accepted in interview

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

    Why on earth is this tagged easy

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

      The solution is supposed to be simpler:
      def findKthPositive(self, arr: List[int], k: int) -> int:
      arr = set(arr)
      max_num = max(arr)
      not_found = []
      for i in range(1, max_num+1):
      if i not in arr:
      not_found.append(i)
      print(not_found)
      if len(not_found) >= k:
      return not_found[k-1]
      else:
      return max_num + (k - len(not_found))