You are given a string s of length n and an integer k, where n is a multiple of k. Your task is to hash the string s into a new string called result, which has a length of n / k.
First, divide s into n / k substrings, each with a length of k. Then, initialize result as an empty string.
For each substring in order from the beginning:
Return result.
Input: s = "mxz", k = 3
Output: "i"
Explanation:
The only substring: "mxz" , 12 + 23 + 25 = 60 , 60 % 26 = 8 , result[0] = 'i' .
Constraints
1 <= k <= 100
k <= s.length <= 1000
s.length is divisible by k.
s consists only of lowercase English letters.
3271. Hash Divided String
Medium
30 Points
String
Simulation
You are given a string s of length n and an integer k, where n is a multiple of k. Your task is to hash the string s into a new string called result, which has a length of n / k.
First, divide s into n / k substrings, each with a length of k. Then, initialize result as an empty string.
For each substring in order from the beginning:
Return result.