Next Permutation From Pool - Facebook Top Interview Questions
You are given two strings digits and lower both representing decimal numbers. Given that you can rearrange digits in any order, return the smallest number that's larger than lower. You can assume there is a solution. Constraints 1 ≤ n ≤ 100,000 where n is the length of digits 1 ≤ m ≤ 100,000 where m is the length of lower Example 1 Input digits = "852" lower = "100" Output "258" Example 2 Input digits = "090" lower = "0" Output "9" Explanation
View Solution →