当前位置:网站首页>leetcode - 384. Scramble array
leetcode - 384. Scramble array
2022-06-25 12:58:00 【zmm_ mohua】
leetcode - 384. Scramble the array
subject
Code
#include <iostream>
#include <vector>
using namespace std;
vector<int> nums;
vector<int> original;
Solution(vector<int>& nums) {
this->nums = nums;
this->original.resize(nums.size());
copy(nums.begin(), nums.end(), original.begin());
}
vector<int> reset() {
copy(original.begin(), original.end(), nums.begin());
return nums;
}
vector<int> shuffle() {
for(int i = 0; i < nums.size(); i++){
int j = i + rand() % (nums.size() - i);
swap(nums[i], nums[j]);
}
return nums;
}
int main(){
return 0;
}
边栏推荐
- Qt显示FFmpeg解码的图片
- 顺序表的折半查找法
- JS enter three integers a, B and C, and sort them from large to small (two methods)
- Differences between JS and JQ operation objects
- 又是被Visdom搞崩溃的一夜
- First acquaintance with CANopen
- Idea2017 how to set not to automatically open a project at startup
- STM32 在flash中存储float数据
- Using CMD (command prompt) to install MySQL & configure the environment
- JS uses the for loop in the function to insert and delete the array at the specified position
猜你喜欢
Maximum number [abstract rules for abstract sorting]
[data visualization] 360 ° teaching you how to comprehensively learn visualization - Part 1
Geospatial search: implementation principle of KD tree
Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)
Shell learning notes (latest update: 2022-02-18)
[转]以终为始,详细分析高考志愿该怎么填
Why are databases cloud native?
Summer Ending
Three jobs! You can learn this from me (attached with graduation vlog)
微信全文搜索技术优化
随机推荐
Shell learning notes (latest update: 2022-02-18)
JSTL tag: fmt:formatdate tag format Chinese standard time or timestamp
Jupyter notebook theme font setting and automatic code completion
Why are databases cloud native?
Negative sample image used in yolov5 training
剑指offer 第 3 天字符串(简单)
画图常用配色
剑指 Offer 第 1 天栈与队列(简单)
Online service emergency research methodology
英语口语 - 连读
Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)
leetcode - 384. 打乱数组
Another night when visdom crashed
mysql导入导出数据到excel表日期出现问题
JS function exercises
地理空间搜索 ->R树索引
Capabilities required by architects
[Visio]平行四边形在Word中模糊问题解决
20220620 interview reply
Baidu search stability analysis story