当前位置:网站首页>leetcode - 384. 打乱数组
leetcode - 384. 打乱数组
2022-06-25 12:20:00 【zmm_mohua】
leetcode - 384. 打乱数组
题目

代码
#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;
}
边栏推荐
- [转]以终为始,详细分析高考志愿该怎么填
- [AI helps scientific research] fool drawing of loss curve
- Oracle backup or restore database (expdp, impdp)
- list. replace, str.append
- 3+1保障:高可用系统稳定性是如何炼成的?
- Qt5 multi thread operation implemented by object base class and use of movetothread method
- Event triggered when El select Clear clears content
- Geospatial search - > R tree index
- GPS NMEA protocol, 0183 positioning data format dual mode positioning: gnxxx gps+bd full version
- Differences between JS and JQ operation objects
猜你喜欢

Koa frame

J2EE从入门到入土01.MySQL安装

百度搜索稳定性问题分析的故事

Singleton mode in PHP to reduce memory consumption

Guess Tongyuan B
![[data visualization] 360 ° teaching you how to comprehensively learn visualization - Part 1](/img/36/167397ce61240036c865dd99463f1b.jpg)
[data visualization] 360 ° teaching you how to comprehensively learn visualization - Part 1

【AI助力科研】loss曲线傻瓜式绘制

Laravel excel export

Wechat full-text search technology optimization

高性能负载均衡架构如何实现?
随机推荐
My first experience of go+ language -- a collection of notes on learning go+ design architecture
Go novice exploration road 2
Laravel task scheduling
Figure explanation of fiborache sequence
2021-09-30
冷启动的最优解决方案
Write regular isosceles triangle and inverse isosceles triangle with for loop in JS
Another night when visdom crashed
1251- Client does not support authentication protocol MySql错误解决方案
visual studio2019链接opencv
三入职场!你可以从我身上学到这些(附毕业Vlog)
英语口语 - 连读
PPT绘论文图之导出分辨率
几分钟上线一个网站 真是神器
Jupyter Notebook主题字体设置及自动代码补全
CUDA error: unspecified launch failure
Go from 0 to 1. Obtain the installation package, get, post request, params, body and other parameters
(5) Pyqt5 ---- another method of connecting signals and slots
Oral English - continuous reading
地理空间搜索:kd树的实现原理