Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int count = 0;
- int currentComprimation = -1;
- String s ="aabbbccccc";
- for (int i = 0; i < s.length(); i++) {
- if(currentComprimation == s.charAt(i)) {
- count++;
- } else {
- if(currentComprimation != -1) {
- System.out.print((char) currentComprimation + "" + count);
- }
- count = 1;
- currentComprimation = s.charAt(i);
- }
- }
- System.out.print((char)currentComprimation + "" + count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement