Java: Kth smallest Element in row-wise and column-wise sorted 2D array

Level : Intermediate
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:30:00

Lab Details

Difficulty Level: MEDIUM

Problem Statement:

Given an n x n matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the given 2D array.

Input:

k = 3 and array =

        10, 20, 30, 40

        15, 25, 35, 45

        24, 29, 37, 48

        32, 33, 39, 50

Output:

The 7th smallest element is 30


Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this