摘要: 1.只需要遍历数组一遍;使用start记录存储0的位置;使用end记录存储2的位置;A[cur]等于1时往后移动cur;A[cur]等于其他则进行交换;class Solution {public: inline void swap( int &a, int &b) { int tmp; tmp=a; a=b; b=tmp; } void sortColors(int A[], int n) { // Start typing your C/C++ solution below ... 阅读全文
posted @ 2013-06-18 21:04 NinaGood 阅读(201) 评论(0) 推荐(0) 编辑