Simple java solution


  • 0
    G

    class Solution {
    public boolean isAnagram(String s, String t) {
    if(s == null || t == null){
    return true;
    }
    if(s.length() != t.length()){
    return false;
    }

        StringBuilder sb = new StringBuilder(t);
        int size = s.length();
        for(int i = 0; i < size; i++){
            char ch = s.charAt(i);
            for(int j = 0; j < sb.length(); j++){
                if(ch == sb.charAt(j)){
                    sb.deleteCharAt(j);
                    break;
                }
            }
        }
        if(sb.length() != 0){
            return false;
        }
        return true;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.