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.
Hey here is my code in python 3!! All test cases passes with just tiny code below:
import sys
N = int(input().strip())
C = input().strip()
count=1
for i in range(len(C)-1):
if len(set(C))==1:
break
else:
if C[i]!=C[i+1]:
count+=1
print(count)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Paint The Tiles
You are viewing a single comment's thread. Return to all comments →
Hey here is my code in python 3!! All test cases passes with just tiny code below:
import sys N = int(input().strip()) C = input().strip() count=1 for i in range(len(C)-1):
if len(set(C))==1: break else: if C[i]!=C[i+1]: count+=1 print(count)