You are given an array of positive integers nums and a positive integer k.
A permutation of nums is said to form a divisible concatenation if, when you concatenate the decimal representations of the numbers in the order specified by the permutation, the resulting number is divisible by k.
Return the lexicographically smallest permutation (when considered as a list of integers) that forms a divisible concatenation. If no such permutation exists, return an empty list.
Example: For nums = [232, 124, 456] and k = 4, the permutation [124, 232, 456] creates the number 124232456, which we need to check if it's divisible by 4.
Input & Output
Visualization
Time & Space Complexity
n numbers, 2^n possible masks, k possible remainders
DP table storing states for each mask and remainder combination
Constraints
- 1 โค nums.length โค 8
- 1 โค nums[i] โค 108
- 1 โค k โค 400
- All integers in nums are unique