大家好,我是毛毛。ヾ(´∀ ˋ)ノ
廢話不多說開始今天的解題Day~
We define the usage of capitals in a word to be right when one of the following cases holds:
"USA"
."leetcode"
."Google"
.Given a string word
, return true
if the usage of capitals in it is right.
Input: word = "USA"
Output: true
Input: word = "FlaG"
Output: false
1 <= word.length <= 100
word
consists of lowercase and uppercase English letters.首先先簡單的翻譯一下題目
給一個字串,判斷是不是符合題目的規則。
作法大致上是這樣
class Solution:
def isPalindrome(self, x: int) -> bool:
x = str(x)
left = 0
right = len(x)-1
while left < right:
if x[left] != x[right]:
return False
left += 1
right -= 1
return True
大家明天見