3
int numPermsDISequence(string s) {5
queue<pair<string, unordered_set<int>>> q;8
for (int i = 0; i <= n; ++i) {16
unordered_set<string> visall;23
auto temp = q.front();25
if (visall.find(temp.first) != visall.end()) {29
for (int j = temp.first.back() - '0' - 1; j >= 0; --j) {30
if (temp.second.find(j) == temp.second.end()) {31
temp.first += (j + '0');32
temp.second.insert(j);33
if (visall.find(temp.first) == visall.end()) {34
q.push({temp.first, temp.second});37
temp.first.pop_back();41
for (int j = temp.first.back() - '0' + 1; j <= n; ++j) {42
if (temp.second.find(j) == temp.second.end()) {43
temp.first += (j + '0');44
temp.second.insert(j);45
if (visall.find(temp.first) == visall.end()) {46
q.push({temp.first, temp.second});49
temp.first.pop_back();