Given a string s, determine the length of the longest signal sequence where characters alternate between being dots (represented as 'X') and dashes (represented as 'Y').
Explanation: Step-by-step: with input XY, we do A then B, giving output 2. The longest alternating sequence is XY, and its length is 2.
Explanation: Step-by-step: with input XYX, we do A then B then A, giving output 3. The longest alternating sequence is XYX, and its length is 3.
Master coding challenges related to Strings and solve the [Backup] Galactic Morse Encoder problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak