Description
Solutions
Smallest Number Greater Than K
📚RELATED PROBLEMS
You are given an integer n
and a threshold integer k
. Your task is to form the smallest number possible from the digits of n
by deleting some digits, while maintaining the original order of the digits. The formed number must be greater than k
.
Details:
n
.k
, try to include additional digits from n
to ensure the result is greater than k
.Function Signature:
string smallestNumberGreaterThanK(string numStr, int k);
Example 1:
Input: numStr = "7195", k = 16
Output: "19"
Explanation:For
n = 7195
andk = 16
, the output should be19
.
Example 2:
Input: numStr = "7195", k = 14
Output: "15"
Explanation:For
n = 7195
andk = 14
, the output should be15
.
Constraints:
🥑🥑

Related Problems
Testcase
Result
Case 1
input:
output: