Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. /**
  2. * Count the number of Duplicates
  3. * Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in    * the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
  4.  
  5. * Example
  6. * "abcde" -> 0 # no characters repeats more than once
  7. * "aabbcde" -> 2 # 'a' and 'b'
  8. * "aabBcde" -> 2 # 'a' occurs twice and 'b' twice (bandB)
  9. * "indivisibility" -> 1 # 'i' occurs six times
  10. * "Indivisibilities" -> 2 # 'i' occurs seven times and 's' occurs twice
  11. * "aA11" -> 2 # 'a' and '1'
  12. * "ABBA" -> 2 # 'A' and 'B' each occur twice
  13. */
  14.  
  15. class Main {
  16.     public static void main(String[] args) {
  17.         System.out.println("Output should be 0: " + duplicateCount("abcde"));
  18.         System.out.println("Output should be 2: " + duplicateCount("aabbcde"));
  19.         System.out.println("Output should be 2: " + duplicateCount("aabBcde"));
  20.         System.out.println("Output should be 1: " + duplicateCount("indivisibility"));
  21.         System.out.println("Output should be 2: " + duplicateCount("Indivisibilities"));
  22.         System.out.println("Output should be 2: " + duplicateCount("aA11"));
  23.         System.out.println("Output should be 2: " + duplicateCount("ABBA"));
  24.     }
  25.    
  26.     public static int duplicateCount(String text) {
  27.         //Your code here
  28.         return -1;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement