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

Sdílet
Vložit
  • čas přidán 13. 09. 2021
  • "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/problems/kth-sma...
    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
  • Věda a technologie

Komentáře • 25

  • @VasheshJ
    @VasheshJ Před 2 lety

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

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

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

    • @VasheshJ
      @VasheshJ Před 2 lety

      @@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 Před rokem

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

  • @CSRookie22
    @CSRookie22 Před rokem

    Appreciate your explanation, very clear.

  • @heyjoe5920
    @heyjoe5920 Před 6 měsíci

    Great explanation, thank you so much.

  • @farukhmahammad9374
    @farukhmahammad9374 Před rokem

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

  • @mohammadyahya78
    @mohammadyahya78 Před 2 lety

    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  Před 2 lety

      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

  • @YogendraRajA
    @YogendraRajA Před 2 lety

    Nice solution!

  • @shreysharma2056
    @shreysharma2056 Před 2 lety

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

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

    gj!!

  • @lalitkashyap1203
    @lalitkashyap1203 Před 2 lety

    thanks

  • @chilly2171
    @chilly2171 Před 2 lety

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

    • @apoorvgupta1211
      @apoorvgupta1211 Před rokem +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.

  • @soltomoon3620
    @soltomoon3620 Před 4 měsíci

    you look like luka doncic

  • @numerobis3949
    @numerobis3949 Před 2 lety

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

    • @pratishbarthwal465
      @pratishbarthwal465 Před 2 lety +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 Před 2 lety

      @@pratishbarthwal465 good point