Advertisement
Kame3

Frequency_of_each_character_just_after_its_consecutive_occurrences

Aug 20th, 2021
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class Main
  2. {
  3.     public static void main(String[] args) throws IOException {
  4.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  5.        
  6.         String input = br.readLine();
  7.         int counter = 0;
  8.        
  9.         for (int i=0; i<input.length(); i++) {
  10.             counter = 1;
  11.             while (i + 1 < input.length() && input.charAt(i) == input.charAt(i + 1)) {
  12.                 i++;
  13.                 counter++;
  14.             }
  15.             System.out.println(input.charAt(i)+" "+counter);
  16.         }
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement