SSS - Simple SWIFT Solution


  • 0
    I

    String manipulation is terrible in Swift :(

    class Solution {
        func detectCapitalUse(_ word: String) -> Bool {
            return  word == word.uppercased() ||
                    word == word.lowercased() ||
                    word[word.index(after: word.startIndex)..<word.endIndex] == word[word.index(after: word.startIndex)..<word.endIndex].lowercased()
            
        }
    }

  • 0
    S

    Your third condition actually covers the second condition already.


Log in to reply
 

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