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
// 冒泡排序 in Flutter List<int> bubbleSort(List<int> arr) { int n = arr.length; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } return arr; } // 快速排序 in Flutter List<int> quickSort(List<int> arr) { if (arr.length <= 1) return arr; int pivot = arr[arr.length ~/ 2]; List<int> left = []; List<int> right = []; for (int i = 0; i < arr.length; i++) { if (arr[i] < pivot) { left.add(arr[i]); } else if (arr[i] > pivot) { right.add(arr[i]); } } return [...quickSort(left), pivot, ...quickSort(right)]; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: