当前位置:网站首页>Color classification of sorting
Color classification of sorting
2022-06-30 14:40:00 【Douglas_ LT】
A daily topic ing, Today is a day medium topic 75. Sort Colors
class Solution {
public:
void sortColors(vector<int>& nums) {
int len=nums.size();
if(len<=1){
return;
}
int i=0;
int zero=0,two=len-1;
while(i<=two){
if(nums[i]==0){
swap(nums[i],nums[zero]);
zero++;
i++;
}
else if(nums[i]==1){
i++;
}
else{
swap(nums[i],nums[two]);
two--;
}
}
}
};
边栏推荐
- Greedy two-dimensional array sorting
- val_ Loss decreases first and then increases or does not decrease but only increases
- Three ways and differences of defining functions in JS
- V3 03_ Getting started
- The first dark spring cup dnuictf
- Error on datetime when importing SQL file from MySQL
- Detailed explanation of the first three passes of upload Labs
- go time. after
- Laravel artist command error
- I love network security for new recruitment assessment
猜你喜欢

1 figure to explain the difference and connection between nodejs and JS

How to use Alibaba Vector Icon

V3 03_ Getting started

The first dark spring cup dnuictf

Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~

Mysql database foundation: stored procedures and functions

val_ Loss decreases first and then increases or does not decrease but only increases

2021 geek challenge Web

Laravel upload error

Ctfshow getting started with the web (ThinkPHP topic)
随机推荐
Impersonate server and client using message queuing
XSS challenge (1-5) more detailed answers
2021-07-15Caused by: org. quartz. ObjectAlreadyExistsException: Unable to store Job : ‘DEFAULT. TASK_ 1‘
Zend studio how to import an existing project
Judgment of deep learning experiment results
Cost forecast of PMP (BAC, EAC, etc)
ThinkPHP v3.2 comment annotation injection write shell
Hbuilder most commonly used and full shortcut key set
go time. after
2021-08-07 native and package types
org. json. The jsonobject object is converted to JSON, and JSON adds new elements. The value is obtained according to the JSON key. And list object format string to jsonarray
Laravel upload error
Uniapp upload image method
Advanced usage of go language for loop break and continue
JS time conversion standard format, timestamp conversion standard format
Implementation of forwarding server using IO multiplexing
Problem: wechat developer tool visitor mode cannot use this function
[extensive reading of papers] analyzing connections between user attributes, images, and text
JS to realize simple lottery function
Detailed explanation of settimeout() and setinterval()