当前位置:网站首页>51. numerical arrangement
51. numerical arrangement
2022-06-23 02:23:00 【Twilight lattice】
Catalog
One 、 Problem description
Enter a set of numbers ( May contain duplicate numbers ), Output all its permutations .
Data range
Enter the array length [0,6].
Examples
Input :[1,2,3]
Output :
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]Two 、 Problem solving
1. Code
class Solution {
public:
vector<vector<int>> permutation(vector<int>& nums) {
sort(nums.begin(),nums.end());
vector<vector<int>> res;
do
{
res.push_back(nums);
}while(next_permutation(nums.begin(),nums.end()));
return res;
}
};next_permutation()
Rearrange elements in scope
[first,last)For the next Dictionary order Bigger array . Permutation is every possible permutation of elements ( among N Is the number of elements in the range ). According to them Dictionaries Sort different permutations by comparing them with each other ; The first possible arrangement in this order ( Press The dictionary order is smaller than Permutations of all other permutations ) Is an arrangement of all elements in ascending order , The largest arrangement is that all elements are arranged in descending order . The comparison of individual elements is done using one of the following methodsN!
边栏推荐
- Operator part
- Dynamic address book in C language (add, delete, modify, check (duplicate), delete, sort and export)
- Uniapp View Horizontal Center
- Score and loop statements (including goto statements) -part3
- JS advanced part
- What is ISBN code and how to make it
- Phpexcel export with picture Excel
- Chapter 3 tensorflow linear regression
- //1.11 basic operators
- 5g core network and core network evolution
猜你喜欢

CSDN browser assistant for online translation, calculation, learning and removal of all advertisements

Rebirth -- millimeter wave radar and some things I have to say

Unity official case nightmare shooter development summary < I > realization of the role's attack function

Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.

Xgboost principle

Interviewer: why does TCP shake hands three times and break up four times? Most people can't answer!

pd. read_ CSV and np Differences between loadtext

How to design API return codes (error codes)?

Deep learning environment configuration (III) pytorch GPU under Anaconda

1. Mx6u image burning principle (no specific process)
随机推荐
1. Mx6u bare metal program (2) - Lighting master (imitating 32 register version)
Get the structure of the class through reflection, little chestnut
What is a smart farm?
5g access network and base station evolution
Arm assembly syntax
//1.11 basic operators
JS case: support canvas electronic signature function on PC and mobile
Use of apicloud AVM framework list component list view and flex layout tutorial
Understand GB, gbdt and xgboost step by step
Troubleshooting and solution of 4K video cannot be played on easydss live video on demand platform
JS to realize the rotation chart (riding light). Pictures can be switched left and right. Moving the mouse will stop the rotation
The commercial s2b2b e-commerce platform of aquatic industry improves the competitiveness of enterprises and creates a strong engine for industrial development
//1.17 printf function
Performance test -- 14 detailed explanation of performance test report and precautions
Analysis of ThreadLocal
//1.16 getchar function
Bubble sort - double for implementation
JS advanced part
Cut! 39 year old Ali P9 saved 150million
About the use of mock framework