当前位置:网站首页>next_ Permutation full permutation function
next_ Permutation full permutation function
2022-06-24 18:34:00 【One star accompanies the moon】
First of all, the header of this function is in the file < algorithm >
next_permutation() It is arranged in dictionary order , And it increases from the current dictionary order in the array to the maximum dictionary order
Reference link
therefore , This function is used only for ordered arrays
Take the topic of force deduction as an example : The first K Sort by
class Solution {
public:
string getPermutation(int n, int k) {
if(!n) return "";
vector<char> ch;
for(int i=0;i<n;i++) ch.push_back(i+1+'0');
int i=0;
do{
if(++i==k) break;
}while(next_permutation(ch.begin(),ch.end()));
string str;
for(auto i : ch){
str+=i;
}
return str;
}
};
边栏推荐
- Knowledge points of 2022 system integration project management engineer examination: ITSS information technology service
- What is decision intelligence?
- [golang] leetcode intermediate - jumping game & different paths
- 基于BGP实现纯三层容器网络方案
- What if the database table structure changes? Smartbi products support one click synchronization
- Regression testing strategy for comprehensive quality assurance system
- Five advantages and disadvantages of Bi
- Usage of typedef enum (enumeration)
- Business based precipitation component = & gt; manage-table
- Huitongda officially landed at the Hong Kong Stock Exchange: the gross profit margin continued to decline, and the book value of several shareholders still suffered losses
猜你喜欢

Redis learning -- list of redis operations

Mariana Trench, Facebook's open source code analysis tool

Recommend a distributed JVM monitoring tool, which is very practical!

Leetcode weekly buckle 281

Several key points for enterprises to pay attention to digital transformation

SDL: cannot play audio after upgrading openaudio to openaudiodevice

Flutter dart regular regexp special characters $, () (IV)

SAP license: SAP s/4 Hana module function introduction

Three layer switching experiment

Project Management Guide: tips, strategies and specific practices
随机推荐
【leetcode】838. Push domino (Analog)
Specification for self test requirements of program developers
How MySQL works - Chapter 14
Vite+web3:报错出现ReferenceError: process is not defined
717.1-bit and 2-bit characters [sliding window]
EasyGBS视频平台TCP主动模式拉流异常情况修复
[can you really use es] Introduction to es Basics (I)
Ten software development indicators for project managers
Get the actual name of the method parameter through the parameter
13 ways to reduce the cost of cloud computing
Digital trend analysis of B2B e-commerce market mode and trading capacity in electronic components industry
SAP license:sap s/4hana is the answer
Why should state-owned enterprises accelerate the digital transformation
Project Management Guide: tips, strategies and specific practices
Implementation of pure three-layer container network based on BGP
EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化
Considerations for it project demand analysis
How to select the best test cases for automation?
EasyNVR使用Onvif探测设备失败,显示“无数据”是什么原因?
如何在 R 中使用 Fisher 的最小显着性差异 (LSD)