题目:整数排序Ⅱ
问题描述:给一组整数,按照升序排序。使用归并排序,快速排序,堆排序或者任何其他 O(n log n) 的排序算法。
思路:使用sort函数排序。
代码:
class Solution {
public:
/**
* @param A an integer array
* @return void
*/
void sortIntegers2(vector<int>& A) {
// Write your code here
sort(A.begin(),A.end());
}
};
感想:有些问题使用函数会特别简单方便。