Practice/Microsoft/Leetcode 93. Restore IP Addresses
CodingMust
You are given a string s containing alphanumeric characters and an integer k representing the number of segments you need to create. Your task is to generate all possible valid email-like format strings by inserting exactly k-1 separators into the string.
The format works as follows:
k-1 separator characters (dots .) into the string to create k segmentsk-1 segments are separated by dotsk > 1, place an @ symbol before the last segment instead of a dotReturn all possible valid formatted strings in any order.
k-1 separators to create k segmentsk-1 segments should be separated by dots (.)@ symbol1 <= s.length <= 12s contains only alphanumeric characters1 <= k <= min(s.length, 4)k segmentsExample 1:
` Input: s = "abc123", k = 2 Output: ["a.bc@123", "ab.c@123", "abc@1.23", "abc@12.3"] Explanation: We need to split into 2 segments with an @ separator.
Example 2:
Input: s = "user", k = 2 Output: ["u@ser", "us@er", "use@r"] Explanation: Split into 2 segments. Possible splits are at positions 1, 2, and 3.
Example 3:
Input: s = "xyz", k = 3 Output: ["x.y@z"] Explanation: With 3 characters and 3 segments needed, we can only split as x, y, z. Format as "x.y@z" (first two separated by dot, last one after @).