DEV Community
•
2026-03-19 15:30
Finding the Kth Smallest Element in an Array
In this task, I worked on finding the kth smallest element in an array. This problem is slightly different from just finding the minimum or maximum because here we need to find a specific position after sorting.
What I Did
I created a function called kth_smallest that takes two inputs:
an array of numbers
a value k (which represents the position)
For example:
Input: [10, 5, 4, 3, 4...