HW1/src/com/company/Main.java
//Question 4: Write a program to check if two strings are anagrams. Anagrams are strings which can be made by rearranging characters in string.
Question 4: Write a program to check if two strings are anagrams. Anagrams are strings which can be made by rearranging characters in string.
Question 4 : Write a program to check if two strings are anagrams . Anagrams are strings which can be made by rearranging characters in string .
public static boolean ifAnagrams(String a, String b) {
        if (a.length() != b.length()) return false;
        int first = 0;
        int second = b.length() - 1;
        while (second >= 0) {
            if (a.charAt(first) != b.charAt(second)) {
                return false;
            } else {
                first++;
                second--;
            }
        }
        return true;
    }
public static boolean ifAnagrams ( String a , String b ) { if ( a . length ( ) != b . length ( ) ) return false ; int first = 0 ; int second = b . length ( ) - 1 ; while ( second >= 0 ) { if ( a . charAt ( first ) != b . charAt ( second ) ) { return false ; } else { first ++ ; second -- ; } } return true ; }
Question 4: Write a program to check if two strings are anagrams.
Question 4 : Write a program to check if two strings are anagrams .