Magical String Shift

Problem Understanding:
You are given a string S consisting of lowercase English letters.

Chef defines a magical operation where:

  • Every character at an even index is shifted +1 in the alphabet

  • Every character at an odd index is shifted -1 in the alphabet

Note:

  • 'z' + 1 → 'a'

  • 'a' - 1 → 'z'


Task:
Print the new transformed string after applying the magical operation.


Input Format:
A single string S


Output Format:
Print the transformed string


Constraints:

  • 1 ≤ |S| ≤ 10⁵

  • S contains only lowercase letters


Example 1:

Input:

abcde

Output:

badcf

Explanation:

Index: 0 1 2 3 4

String: a b c d e

  • index 0 → a → b

  • index 1 → b → a

  • index 2 → c → d

  • index 3 → d → c

  • index 4 → e → f

Result → badcf


Example 2:

Input:

zebra

Output:

afcqa

Time Complexity:

O(n)


Space Complexity:

O(n)

I think there is an issue with Example 2.

For input zebra, applying the given rules:

  • index 0 (z) → a

  • index 1 (e) → d

  • index 2 (b) → c

  • index 3 (r) → q

  • index 4 (a) → b

This gives the result adcqb.

However, the provided output is afcqa, which does not follow the described transformations (notably at indices 1 and 4).

Could you please clarify if this is a typo in the example?

The mistake was in the example output, which did not correctly apply the even (+1) and odd (-1) transformation rules