Caesar Cipher Decryption

Problem Decrypt an array/string of letters encoded with a Caesar-style shift: each plaintext letter was shifted forward by K; shifting back with wraparound recovers it. Pin the exact shift semantics with an example before coding — some framings state the shift indirectly and are deliberately confusing.

Input / Output

  • Input: the encoded letters and a shift parameter K.
  • Output: the decoded letters.

Constraints

  • Length and K up to 10^5 -> reduce K mod 26 once.
  • Preserve case; leave non-letters untouched (clarify).

Example

  • With effective shift 2: "CD" -> "AB".
  • Wraparound: "AB" with shift 2 -> "YZ".
asked …
LeaderboardSalaryAccount