You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); String C = in.next(); char[] arr = new char[N]; arr = C.toCharArray(); int count = 1; for(int i=0; i<N-1; i++) { if(arr[i] != arr[i+1]) count++; } System.out.println(count); }
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 →