当前位置:网站首页>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)
边栏推荐
- Redis cache avalanche, penetration, breakdown
- Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
- 小程序 多tab 多swiper + 每个tab分页
- Five problems of database operation in commodity supermarket system
- The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
- How to install PHP on Ubuntu 20.04
- Win 11 major updates, new features love love.
- Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
- Win32: analyse du fichier dump pour la défaillance du tas
- [combinatorics] generating function (positive integer splitting | unordered | ordered | allowed repetition | not allowed repetition | unordered not repeated splitting | unordered repeated splitting)
猜你喜欢

What London Silver Trading software supports multiple languages

2022-2028 global lithium battery copper foil industry research and trend analysis report

一入“远程”终不悔,几人欢喜几人愁。| 社区征文

Bidding procurement scheme management of Oracle project management system

2022-2028 global scar care product industry research and trend analysis report

Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition

How to expand the capacity of golang slice slice

Investigation on the operation prospect of the global and Chinese Anti enkephalinase market and analysis report on the investment strategy of the 14th five year plan 2022-2028

Three gradient descent methods and code implementation
![[untitled]](/img/83/5a57ed90aaafde94db600246256867.jpg)
[untitled]
随机推荐
English語法_名詞 - 分類
Use of unsafe class
Golang string (string) and byte array ([]byte) are converted to each other
Setinterval CPU intensive- Is setInterval CPU intensive?
[Tongxin UOS] scanner device management driver installation
The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
Class exercises
How to deploy applications on kubernetes cluster
2022-2028 global marking ink industry research and trend analysis report
解决Zabbix用snmp监控网络流量不准的问题
Graduation summary
[combinatorics] generating function (property summary | important generating function)*
Postfix tips and troubleshooting commands
微服务组件Sentinel控制台调用
圖像24比特深度轉8比特深度
聊聊支付流程的設計與實現邏輯
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
Naoqi robot summary 27
Remote office tools sharing | community essay solicitation
A. Odd Selection【BruteForce】