当前位置:网站首页>Niuke: rotation array
Niuke: rotation array
2022-06-25 11:24:00 【lsgoose】

This problem is done with array flipping , Didn't you think ...
It's amazing , From the example of the topic :
123456 Flip whole into 654321
Then we flip the front 2 Bit becomes 564321, After flipping 4 And the bits become 561234, Isn't that amazing ....
At first I thought of using circular shift to do ...
The answer is as follows :
class Solution {
public:
/**
* Rotated array
* @param n int integer The length of the array
* @param m int integer Shift right distance
* @param a int integer vector Given array
* @return int integer vector
*/
vector<int> solve(int n, int m, vector<int>& a) {
m = m%n;
reverse(a.begin(), a.end());
reverse(a.begin(), a.begin()+m);
reverse(a.begin()+m, a.end());
return a;
}
};边栏推荐
- try-catch-finally
- 手机上股票开户安全吗?找谁可以开户啊?
- 某APP中模拟器检测分析
- MySQL and Oracle processing CLOB and blob fields
- 基于OpenStreetMap+PostGIS的地理位置系统 论文文档+参考论文文献+项目源码及数据库文件
- Jincang database kingbasees plug-in identity_ pwdexp
- SQL injection vulnerability (bypass)
- Arrays. asList()
- SystemVerilog(十三)-枚举数据类型
- 基于Minifilter框架的双缓冲透明加解密驱动 课程论文+项目源码
猜你喜欢
随机推荐
3 Questions par jour (3) - vérifier l'existence d'entiers et de leurs doubles
牛客网:主持人调度
今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界
Daily 3 questions (2) - find out the lucky numbers in the array
基于OpenStreetMap+PostGIS的地理位置系统 论文文档+参考论文文献+项目源码及数据库文件
基于超算平台气象预警并行计算架构研究
手机上股票开户安全吗?找谁可以开户啊?
Comparison between relu and SIGMOD
Free access to the global human settlements layer (ghsl) dataset from Gee
Tidb applicable scenarios
Kingbasees plug-in DBMS of Jincang database_ UTILITY
SQL注入漏洞(繞過篇)
Getting started with Apache Shenyu
Ladder Side-Tuning:预训练模型的“过墙梯”
金仓数据库 KingbaseES 插件force_view
从GEE中免费获取全球人类住区层 (GHSL) 数据集
SystemVerilog (XIII) - enumerate data types
Spannable 和 Editable、SpannableString 和 SpannableString
GC
反应c语言程序结构特点的程序









