当前位置:网站首页>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--;
}
}
}
};
边栏推荐
- @PathVariable
- [extensive reading of papers] multi modal sarcasm detection and human classification in code mixed conversations
- I love network security for new recruitment assessment
- PS dynamic drawing
- Add attributes to multimode
- How does hbuilder display in columns?
- Chapter 13 signal (III) - example demonstration
- V3 02——What‘s new in Chrome extensions
- Fastcgi CGI shallow understanding
- Shell programming overview
猜你喜欢

XSS challenge (6-10) more detailed answers

remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac

Introduction to the construction and development of composer private warehouse

Laravel configures passport and returns token using JWT

Att & CK red team evaluation field (I)

PS dynamic drawing

Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package

The first dark spring cup dnuictf

Shell programming overview

DefCamp Capture the Flag (D-CTF) 2021-22 web
随机推荐
PS cutting height 1px, Y-axis tiling background image problem
Begin End use the pit encountered
LIS error: this configuration section cannot be used in this path
JS array sorting method summary
PHP recursive multi-level classification, infinite classification
数据恢复软件EasyRecovery15下载
Small exercise of process and signal
[extensive reading of papers] multimodal attribute extraction
go channel && select
@Role of ResponseBody
2021-07-14 mybaitsplus
Impersonate server and client using message queuing
About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)
2021-05-12
Getting started with shell Basics
Fastcgi CGI shallow understanding
In situ merging of two arrays with two pointers
V3 03_ Getting started
【BUUCTF】 EasySql
Meaning of while (~scanf ("%d%d", & A, & B))