当前位置:网站首页>189. Rotation array
189. Rotation array
2022-07-03 18:19:00 【The_ Dan】
class Solution {
public:
void rotate(vector<int>& nums, int k) {
int n = nums.size();
k = k % n;
reverse(nums, 0, n - 1);
reverse(nums, 0, k - 1);
reverse(nums, k, n - 1);
}
void reverse(vector<int>& nums, int begin, int end){
while(begin < end){
swap(nums[begin], nums[end]);
begin++;
end--;
}
}
};
Accepted
38/38 cases passed (36 ms)
Your runtime beats 7.9 % of cpp submissions
Your memory usage beats 98.48 % of cpp submissions (24.2 MB)
边栏推荐
- How to analyze the rising and falling rules of London gold trend chart
- Naoqi robot summary 27
- Micro service component sentinel console call
- English语法_名词 - 分类
- Design limitations of structure type (struct)
- ES7 - Optimization of promise
- 网格图中递增路径的数目[dfs逆向路径+记忆dfs]
- Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
- [LINUX]CentOS 7 安装MYSQL时报错“No package mysql-server available“No package zabbix-server-mysql availabl
- The vscode code is automatically modified to a compliance code when it is formatted and saved
猜你喜欢
PHP MySQL preprocessing statement
Valentine's day, send you a little red flower~
网格图中递增路径的数目[dfs逆向路径+记忆dfs]
基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
Have you learned the correct expression posture of programmers on Valentine's day?
The vscode code is automatically modified to a compliance code when it is formatted and saved
微服务组件Sentinel控制台调用
2022-2028 global plasmid DNA cdmo industry research and trend analysis report
win32:堆破坏的dump文件分析
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
随机推荐
Image 24 bits de profondeur à 8 bits de profondeur
What kind of experience is it when the Institute earns 20000 yuan a month?
Have you learned the correct expression posture of programmers on Valentine's day?
Golang string (string) and byte array ([]byte) are converted to each other
【统信UOS】扫描仪设备管理驱动安装
[combinatorics] generating function (shift property)
[Tongxin UOS] scanner device management driver installation
A. Berland Poker &1000【简单数学思维】
Research on Swift
2022-2028 global marking ink industry research and trend analysis report
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
How to analyze the rising and falling rules of London gold trend chart
Valentine's day, send you a little red flower~
AcWing 271. 杨老师的照相排列【多维DP】
Line by line explanation of yolox source code of anchor free series network (6) -- mixup data enhancement
Life perception 1
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
PHP MySQL preprocessing statement
Computer graduation design PHP campus address book telephone number inquiry system