HW1/src/com/company/Main.java
//Question 3. Write a program to check if string contains duplicates
Question 3. Write a program to check if string contains duplicates
Question 3 . Write a program to check if string contains duplicates
public static boolean ifDuplicate(String s) {
        if (s == null || s.length() == 0) return false;
        Map<Character, Integer> map = new HashMap<>();
        for (char c : s.toCharArray()) {
            if (map.containsKey(c)) {
                return true;
            } else {
                map.put(c, 1);
            }
        }
        return false;
    }
public static boolean ifDuplicate ( String s ) { if ( s == null || s . length ( ) == 0 ) return false ; Map < Character , Integer > map = new HashMap < > ( ) ; for ( char c : s . toCharArray ( ) ) { if ( map . containsKey ( c ) ) { return true ; } else { map . put ( c , 1 ) ; } } return false ; }
Question 3.
Question 3 .