We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://leetcode.com/problems/sort-an-array/
Modifying the code to the following version will pass the test
class Solution { public int[] sortArray(int[] nums) { quickSort(nums, 0, nums.length - 1); return nums; } public static void quickSort(int[] arr, int left, int right) { var pivotIndex = left + (right - left) / 2; var pivotValue = arr[pivotIndex]; var i = left; var j = right; while (i <= j) { while (arr[i] < pivotValue) { i++; } while (arr[j] > pivotValue) { j--; } if (i <= j) { var tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i++; j--; } } if (left < j) { quickSort(arr, left, j); } if (right > i) { quickSort(arr, i, right); } } }
The text was updated successfully, but these errors were encountered:
can you assign it to me?
Sorry, something went wrong.
chaitaannya
No branches or pull requests
https://leetcode.com/problems/sort-an-array/
Modifying the code to the following version will pass the test
The text was updated successfully, but these errors were encountered: