String Challenge (Generic)

Problem Overview

  • Compute the minimum number of changes to make every character have an identical adjacent neighbor in the caption.
  • Input: a lowercase string 'a'–'z' (length 2 to 1e5); Output: the minimal count of edits.
  • Allowed edit: change any letter to its immediate predecessor or successor; 'a' can't go left and 'z' can't go right.
  • Real-world context: refining TikTok Academy video captions.
  • From TikTok interviews; a coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: