Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1.
Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, return -1.
voidrecursive(string& maxNum, string& num, map<char, int>& digits, string cur){ if(cur.length() == maxNum.length()) { long a = stol(maxNum), b = stol(num), c = stol(cur); if(a > c && c > b) maxNum = cur; return; }