void sortColors(vector<int>& nums){
int pivovIndex = 0;
int currentColor = 0;
while(pivovIndex < nums.size()){
for(int i = pivovIndex; i < nums.size(); i++){
if(nums[i] == currentColor){
std::swap(nums[pivovIndex], nums[i]);
pivovIndex++;
}
}
currentColor++;
}
}
'Problem set' 카테고리의 다른 글
[LeetCode] Maximum Subarray - Kadane Algorithm (0) | 2022.09.21 |
---|---|
[LeetCode] Sort-Array-By-Parity-ii (0) | 2022.08.26 |
[LeetCode] Find Pivot Index (0) | 2022.08.26 |
[LeetCode] Move Zeroes (0) | 2022.08.26 |
[백준] 1967 트리의 지름 (0) | 2021.02.20 |