How To Find Median Of Row Wise Sorted Matrix ? | FREE DSA Course in JAVA | Lecture 84

Sdílet
Vložit
  • čas přidán 26. 07. 2024
  • Let's see a very interesting question asked in Amazon to find the median of a matrix.
    The questions read as:-
    We have to write a program in Java to find the median of a matrix where the matrix has certain conditions namely:-
    1. The total elements in the matrix are odd.
    2. All elements in a row are sorted
    So basically we have to find the median of a row-wise sorted array.
    Let's see the naive approach for the same.
    We can store the matrix in a linear array of size rows*columns and store the matrix elements in it.
    Now we can sort this 1D array using the sort function.
    Finally, we can find the medium using the formula of the median for an odd number of elements ie. (n+1)/2.
    Why would Amazon ask such a simple question in its coding round?
    The problem is that the suggested naive approach is not efficient. It requires more time and space.
    Hence we have to come up with an efficient approach to solve this program in order to write a code with minimum time complexity.
    Let's see how we can do it?
    Subscribe ‪@TAPACADEMY‬
    Check out our FREE DSA playlist here - • Data Structures And Al...
    For more information, fill out this form: forms.gle/8eiUmM92Fx563Aen9
    or call us at 8884881203
    Facebook: / thetapacademy
    Instagram: / tapacademy_online
    Linkedin: / 73820805
    Website: www.thetapacademy.com​
    #java #dsa #datastructures #algorithms #programming #array #arrayjava #java #javaprogramming

Komentáře • 4

  • @sanketh768
    @sanketh768 Před rokem +1

    even though this was a lengthy video it made me understand the solution in detail.
    Thank you very much sir

  • @ayushmishra9758
    @ayushmishra9758 Před rokem +1

    GOAT🐐🐐

  • @manwinsingh7381
    @manwinsingh7381 Před 5 měsíci

    Where is the other sir

  • @extrabgmi2788
    @extrabgmi2788 Před rokem +1

    ❤️❤️❤️❤️❤️