Kth Smallest Element Problem Statement

You are provided with an array of integers ARR of size N and an integer K. Your task is to find and return the K-th smallest value present in the array. All elements in the array are distinct.

Example:

Input:
T = 1
N = 5, K = 3
ARR = [3, 1, 4, 2, 5]
Output:
3
Explanation:

The sorted array is [1, 2, 3, 4, 5]. The 3rd smallest element is 3.

Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 10^4
  • 1 <= K <= N
  • 1 <= ARR[i] <= 10^9
  • Time limit: 1 sec.
Be the first one to answer
Add answer anonymously...
Compass Group Support Services Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter