当前位置:网站首页>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;
}
};
边栏推荐
- It is often blocked by R & D and operation? You need to master the 8 steps before realizing the requirements
- Why should state-owned enterprises accelerate the digital transformation
- [North Asia data recovery]_ mdb_ catalog. Mongodb database data recovery case in case of WT file corruption
- Redpacketframe and openmode packages
- Sword finger offer 10- ii Frog jumping on steps
- Three indicators to help you measure the effectiveness of digital transformation
- 如何在 R 中创建线性模型预测区间 并可视化
- How MySQL works - Chapter 14
- 【你真的会用ES吗】ES基础介绍(一)
- R language Quantitative Ecology redundancy analysis RDA analysis plant diversity species data visualization
猜你喜欢

Mariana Trench, Facebook's open source code analysis tool

Business leaders compete for CIO roles

How does the chief information security officer discuss network security with the enterprise board of directors

It is often blocked by R & D and operation? You need to master the 8 steps before realizing the requirements

Recommend 14 commonly used test development tools

Overall planning and construction method of digital transformation
Paper sharing | self supervised learning paper jointly released by Yann Lecun and read by engineers

SAP license: SAP s/4 Hana module function introduction
[North Asia data recovery]_ mdb_ catalog. Mongodb database data recovery case in case of WT file corruption
About swagger
随机推荐
Business based precipitation component = & gt; manage-table
如何在 R 中执行稳健回归
Flutter dart regular regexp matches non printing characters \cl\cj\cm\ck
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
Digital trend analysis of B2B e-commerce market mode and trading capacity in electronic components industry
[NLP] 3 papers on how Stanford team builds a better chat AI
如何在 R 中执行幂回归
Implementation of pure three-layer container network based on BGP
About pyqt5 to realize paging function (one window implements different interfaces)
SAP license: ERP for supply chain management and Implementation
[untitled]
Bigdecimalavoiddoubleconstructorrule: do not directly use the double variable as a parameter to construct BigDecimal
Leetcode skimming questions - the 72nd biweekly match and 281 weekly match
Can the money invested in financial products be withdrawn at any time?
解决执行MapReduce程序控制台没有日志信息WARN Please initialize the log4j system properly
面试算法 - 字符串问题总结
25.sql statement differentiation
Network security database penetration of secondary vocational group in 2022
Get the actual name of the method parameter through the parameter
What if the database table structure changes? Smartbi products support one click synchronization