Mr_HO1A

JAVA Solution

Oct 9th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1.  
  2. package javaapplication1;
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class JavaApplication1 {
  8.  
  9.     public static void main(String[] args) {
  10.         int count=0;
  11.         String in = "ab26cd72ef7g8h9ayush101gau";
  12.         boolean previous = false;
  13.         Scanner s = new Scanner(System.in);
  14.         String input = s.nextLine();
  15.         char characters[] = in.toCharArray();
  16.         for(char a : characters){
  17.             if(Character.isDigit(a)){
  18.                 if(previous == true){
  19.                     continue;
  20.                 }
  21.                 previous = true;
  22.                 count++;
  23.             }
  24.             else{
  25.                 previous = false;
  26.             }
  27.         }
  28.         System.out.println(count);
  29.     }
  30.    
  31. }
Add Comment
Please, Sign In to add comment