Swift - not sure if it's simple enough


  • 1
    S
    func isAnagram(s: String, _ t: String) -> Bool {
        
        if s.characters.count != t.characters.count {
            
            return false
            
        } else {
        
            if s.characters.sort() == t.characters.sort() {
                
               return true
                
            } else {
                
                return false
            }
            
        }
    }

Log in to reply
 

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