DEV Community

Ganga Sri V
Ganga Sri V

Posted on

Kth Smallest Element

Problem Statement:

Given an integer array arr[] and an integer k, your task is to find and return the kth smallest element in the given array.

My Approach:

Step-1:First I Sort the array in ascending order
Step-2:Then I Return the element at index k-1 because array index starts from 0 then kth smallest means position k-1

Method Used:

Sorting
Direct indexing

Top comments (0)