Intuitive Java solution

  • 5
    public class Solution {
        public boolean isAnagram(String s, String t) {
            if(s==null && t == null) return true;
            if(s==null || t == null) return false;
            if(s.length()!=t.length()) return false;
            int[] ct= new int[26];
            for(int i=0; i<s.length();i++){
            for(int i=0; i<t.length();i++){
                if(ct[t.charAt(i)-'a']<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.