title: Find kth largest element using quick select algorithm
body: <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  class Solution {
  public:
      int partition(vector&lt;int&gt; &amp;nums, int low,int high,int pivotElement)
      {
          int pivotPoint=low;
          for(int i=low;i&lt;=high-1;i++)
          {
              if(nums[i]&lt;=pivotElement)
              {
                  swap(nums[i],nums[pivotPoint]);
                  pivotPoint++;
              }
          }
          swap(nums[pivotPoint],pivotElement);
          return pivotPoint;
          
      }
      int quickSelect(vector&lt;int&gt; &amp;nums, int k,int low,int high)
      {
          int pivotElement=nums[high];
          int pivot=partition(nums,low,high,pivotElement);
          if(pivot==k)
          {   
              return nums[pivot];
          }
          else if(pivot&gt;k)
              return quickSelect(nums,k,low,pivot-1);
          else
          {   
              return quickSelect(nums,k,pivot+1,high);
          }
      }
      int findKthLargest(vector&lt;int&gt;&amp; nums, int k) {
       return quickSelect(nums,nums.size()-k,0,nums.size()-1);
      }
  };
  int main(){
  vector&lt;int&gt; v={3,2,1,5,6,4};
  Solution ob;
  cout&lt;&lt;ob.findKthLargest(v,2);
  }
  </code></pre>
  <p>This is my code, I have used quick select algorithm. In this question i am aimed to get kth largest element. It is giving wrong answer on some test cases though i have tried to cover everything and many test cases are passed. I tried to use cout statement to fetch the error though as per my dry run I should have got correct output. But when I tried to print the elements after first partition though 4 should have moved to index 3 and 5 at last as per swap but that's not happening 4 is still at last and 5 at index 3. I am unable to figure that out. Kindly help me resolve this. I have tried to explain the issue in best way if any further clarification is required would be more than happy to provide. Thank you.</p>