Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Answer {
- public static int answer(String s) {
- int split = 1;
- char c = s.charAt(0);
- for (int i = 1; i < s.length() - 1; i++) {
- if (c == s.charAt(i)) {
- if(s.charAt(i)!=s.charAt(i+1)){
- split++;
- }
- }
- }
- return split;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement