BackmediumStrings Microsoft

Galactic Transmission Analyzer Solution

Problem Statement

In a deep space transmission, signals are represented as strings of characters. A signal block is a sequence of identical characters. Given a transmission string, count the number of signal blocks, ignoring any single character that does not have any consecutive identical characters.

Example 1
Input
AAAABBBCC
Output
2

Explanation: Step-by-step: 1. Initialize a counter to 0. 2. Iterate through the string. 3. If the current character is the same as the previous one, increment the counter. 4. If the current character is different from the previous one, reset the counter. 5. After iterating through the entire string, return the counter. For input AAAABBBCC, the counter will be incremented for 'AAAABBB' and 'CC', resulting in a final count of 2.

Example 2
Input
ABC
Output
0

Explanation: Step-by-step: 1. Initialize a counter to 0. 2. Iterate through the string. 3. Since 'A' is not the same as 'B' and 'B' is not the same as 'C', the counter will remain 0. Therefore, the final count is 0.

Constraints

  • 1 <= transmission string length <= 1000
  • Transmission string only contains uppercase English letters
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free