class Solution{
    public:
    // arr : given array
    // l : starting index of the array i.e 0
    // r : ending index of the array i.e size-1
    // k : find kth smallest element and return using this function
    int kthSmallest(int arr[], int l, int r, int k) {
       priority_queue<int>maxpq;
       for(int i=l;i<=r;i++)
       {
           maxpq.push(arr[i]);
           if(maxpq.size()>k)
           {
              maxpq.pop();
           }
           
       }
       return maxpq.top();
        
    }
};