Description: https://leetcode.com/problems/detect-capital/
Solution:
def detect_capital_use(word)
(word == word.downcase) ||
(word == word.upcase) ||
(word == word.downcase.capitalize)
end
Explanation:
1- Check if the word is the same after converting it all to downcase.
1.2- Check if the word is the same after converting it all to upcase.
1.3- Check if the word is the same after converting it all to downcase and then converting the first character to upcase.
Top comments (0)