Leetcode 378. Kth Smallest Element in a Sorted Matrix [Java]

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ส.ค. 2024
  • "Kth Smallest Element in a Sorted Matrix" is the coding interview question asked by Amazon. Check out this video to find out how to solve it efficiently using the binary search in Java.
    Question URL: leetcode.com/p...
    Please write in the comments below which leetcode problem you want me to solve next.
    And remember, a leetcode a day keeps unemployment away!
    Thanks for watching!
    #leetcode378
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @VasheshJ
    @VasheshJ 2 ปีที่แล้ว

    Thank you so much. This video was really helpful to understand how the binary search solution worked.

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

      I am very happy that I was able to help you! Thanks for watching!

    • @VasheshJ
      @VasheshJ 2 ปีที่แล้ว

      @@ifelsestatement7803 Hey, I am still not sure abt time complexity. The binary search actually depend on the value of the smallest and largest element of the matrix so time complexity will actually depend on the values?

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

    watched a lot of videos on repeat but your video made it crystal clear in one go... THANK YOU keep it up loved it

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

      Thank you so much for your comment! I am very glad it helped you!

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

    Great explanation, thank you so much.

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

      I am glad it helped you! Thak you for your comment!

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

    Appreciate your explanation, very clear.

  • @YogendraRajA
    @YogendraRajA 2 ปีที่แล้ว

    Nice solution!

  • @mohammadyahya78
    @mohammadyahya78 2 ปีที่แล้ว

    Thank you. Can you make a list of mediums you had please? Also do you have a list of mid-hard questions you would recommend preparing for interview please?

    • @ifelsestatement7803
      @ifelsestatement7803  2 ปีที่แล้ว

      I will add it to my to-do list to make these playlists. In a meantime, definitely check out:
      1) 322. Coin Change
      2) 518. Coin Change 2
      3) 647. Palindromic Substrings
      4) 475. Heaters
      5) 542. 01 Matrix
      6) 46. Permutations

  • @shreysharma2056
    @shreysharma2056 2 ปีที่แล้ว

    in the countLessOrEqual function, why is the starting point in the right most column?
    Thank you for this video by the way, greatly appreciated!

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

    you look like luka doncic

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

    great!!! what's the TC of the last approach?

  • @lalitkashyap1203
    @lalitkashyap1203 2 ปีที่แล้ว

    thanks

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

    gj!!

  • @chilly2171
    @chilly2171 2 ปีที่แล้ว

    isn't the middle element (min + max)/2?

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

      The middle is calculated in this way so as to avoid Integer Overflow. Adding 2 integers may produce a value which exceeds the acceptable integer limits. Hence we calculate the mid in this manner.

  • @numerobis3949
    @numerobis3949 2 ปีที่แล้ว

    min + (max - min)/2 == (min + max)/2

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

      conceptually it is true. But when implemented as (min+max)/2, the result may overflow as we have a permissible range for any datatype. For example, (2147483600+2147483647)/2 would overflow, while 2147483600+(2147483647-2147483600)/2 won't. Mathematically, both are equivalent.

    • @numerobis3949
      @numerobis3949 2 ปีที่แล้ว

      @@pratishbarthwal465 good point