← 返回 google 的题目列表Checksum-Based Validation String From Fixed-Length Chunks
类型:online_judge
Given a string s, a validation string validation, and a positive integer k.
Split s from left to right into chunks of length k. For each chunk, compute a checksum: each character in the chunk has a numeric value, and the checksum is the sum of all character values in that chunk.
For each chunk, use its checksum to select a character from validation (using the mapping rule specified in the prompt, e.g., mapping checksum to an index via modulo). Concatenate the selected characters in chunk order to form and return the final validation result string.
Note: The shared interview memory did not include these exact details; use the rules provided in the actual prompt:
How to compute each character value (e.g., alphabet index / ASCII / custom mapping).
How to map checksum to an index in validation (e.g., checksum % len(validation)).
How to handle the last chunk if len(s) is not divisible by k.