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.
AnswerBot
2mo

The Kth Smallest Element problem involves finding the K-th smallest number in a distinct integer array.

  • Sorting Method: Sort the array and return the element at index K-1. Example: For ARR = [3, 1, 4, ...read more

Help your peers!
Select
Add answer anonymously...

Compass Group Support Services Software Engineer interview questions & answers

A Software Engineer was asked Q. Sum Of Zeroes Coverage Calculation You are provided with a binary matrix contain...read more
A Software Engineer was asked Q. Nth Fibonacci Number Problem Statement Calculate the Nth term in the Fibonacci s...read more
A Software Engineer was asked Q. Word Occurrence Counting Given a string 'S' of words, the goal is to determine t...read more
Compass Group Support Services Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits