Prechádzať zdrojové kódy

Adding solution for 520

Vinicius Teshima 2 týždňov pred
rodič
commit
c69a5a2833
1 zmenil súbory, kde vykonal 27 pridanie a 0 odobranie
  1. 27 0
      Python/520.py

+ 27 - 0
Python/520.py

@@ -0,0 +1,27 @@
+# 520. Detect Capital
+
+import sys
+
+class Solution:
+    def detectCapitalUse(self, word: str) -> bool:
+        if word[0].islower():
+            return all(x.islower() for x in word[1:])
+
+        return all(x.islower() for x in word[1:]) or all(x.isupper() for x in word[1:])
+    pass
+
+def main() -> int:
+    def r(word: str, exp: bool) -> None:
+        ret: bool = Solution().detectCapitalUse(word)
+        print(
+            f"Solution().detectCapitalUse({word}) = {ret} | exp: {exp}"
+        )
+        pass
+
+    r("USA", True)
+    r("FlaG", False)
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main())