Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public class Answer {
  2. public static int answer(String s) {
  3. int split = 1;
  4. char c = s.charAt(0);
  5. for (int i = 1; i < s.length() - 1; i++) {
  6. if (c == s.charAt(i)) {
  7. if(s.charAt(i)!=s.charAt(i+1)){
  8. split++;
  9. }
  10. }
  11. }
  12. return split;
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement