Class Solution
-
- All Implemented Interfaces:
public final class Solution3533 - Concatenated Divisibility.
Hard
You are given an array of positive integers
numsand a positive integerk.A permutation of
numsis 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 byk.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 1:
Input: nums = 3,12,45, k = 5
Output: 3,12,45
Explanation:
The lexicographically smallest permutation that forms a divisible concatenation is
[3,12,45].Example 2:
Input: nums = 10,5, k = 10
Output: 5,10
Explanation:
The lexicographically smallest permutation that forms a divisible concatenation is
[5,10].Example 3:
Input: nums = 1,2,3, k = 5
Output: []
Explanation:
Since no permutation of
numsforms a valid divisible concatenation, return an empty list.Constraints:
1 <= nums.length <= 13<code>1 <= numsi<= 10<sup>5</sup></code>
1 <= k <= 100
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntArrayconcatenatedDivisibility(IntArray nums, Integer k)-
-
Method Detail
-
concatenatedDivisibility
final IntArray concatenatedDivisibility(IntArray nums, Integer k)
-
-
-
-