Ctrl K

Borrow a Later Letter

Easy
You get a string text and an integer step. Encode it as follows: every character is replaced by the character that sits step positions to its right in the **original** string. The string is treated as a ring: once you pass the end, counting continues from the beginning. Return the encoded string.
Example 1
text='lamp', step=1 → 'ampl'

Each letter is replaced by the next one: l → a, a → m, m → p, and for the last letter p we wrap around to the start and take l.

Example 2
text='code', step=6 → 'deco'

A step of 6 in a string of length 4 is the same as a step of 2: c takes d, o takes e, d takes c, e takes o.

Example 3
text='zzz', step=5 → 'zzz'
Constraints
  • 1 ≤ len(text) ≤ 100
  • 1 ≤ step ≤ 10⁹
  • text consists of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
text='lamp', step=1
Expected
'ampl'

Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.