I am getting an error of timelimit in one case

Vanshika, you need to consider the case when all elements of array are reversed, in that case the complexity of quick sort will be o(n^2), Thus you need to use randomised quick sort in your code. You can refer to online video given on randomised quick sort in recursion section of your course.