You are given a license key `s` of letters, digits and dashes, and an integer `k`. Reformat it so every group has exactly `k` characters, except the first group, which may be shorter but must have at least one character. Groups are separated by single dashes and all letters become uppercase. Return the reformatted key.
You are given a license key s of letters, digits and dashes, and an integer k. Reformat it so every group has exactly k characters, except the first group, which may be shorter but must have at least one character. Groups are separated by single dashes and all letters become uppercase. Return the reformatted key.
Example 1:
Input: {"s":"5F3Z-2e-9-w","k":4}
Output: 5F3Z-2E9W
Constraints:
1≤s.length≤105
s consists of English letters, digits, and dashes '-'.
1≤k≤104
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"5F3Z-2e-9-w","k":4}
Build the key from the right end, so every group fills up to k = 4 and only the leftmost group can come out short.