Cipher Cover
Asked at Databricks
Reported by the problem's creator, not verified
A cipher is described by a source string book and a cover: a list of inclusive index intervals [start, end] into book. The cipher text is the pieces of book named by the intervals, joined in the order the intervals are listed. Intervals may be unsorted, may overlap, and may repeat. Every interval satisfies start <= end.
Each test drives one Cipher instance through a sequence of method calls and checks every return value.
Examples
Example 1
Input: init =
["abcdefghij",[[1,4],[7,9]]], operations =[["text",[]],["locate",[0]],["locate",[3]],["locate",[4]],["locate",[6]]]Output:
["bcdehij",[0,1],[0,4],[1,7],[1,9]]Explanation: The cover reads indices 1 to 4 (bcde) and then 7 to 9 (hij), so the text is bcdehij. Position 0 is book index 1 of interval 0, position 3 is book index 4 of interval 0, position 4 is book index 7 of interval 1, and position 6 is book index 9 of interval 1.