Kth Smallest Element in the Array

Find the kth smallest element in an unsorted array of non-negative integers.

Definition of kth smallest element

kth smallest element is the minimum possible n such that there are at least k elements in the array <= n.
In other words, if the array A was sorted, then A[k - 1] ( k is 1 based, while the arrays are 0 based )

You are not allowed to modify the array ( The array is read only ).
Try to do it using constant extra space.


A : [2 1 4 3 2]
k : 3

answer : 2
Interview Code Editor
2788 successful submissions.
Click here to jump start your coding interview preparation