We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Strings
- Alternating Characters
- Discussions
Alternating Characters
Alternating Characters
Sort by
recency
|
1955 Discussions
|
Please Login in order to post a comment
Here are my c++ approaches of solving this, video explanation here : https://youtu.be/KoDlxS38_ig
Solution 1 : Using loop
Solution 2 : Using regex
def alternatingCharacters(s): n = len(s) count = 0 for i in range(n-1): if s[i] == s[i+1]: count += 1 return count
php