MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

Python/detect-capital.py:22–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20Space Complexity: O(1)
21'''
22class Solution:
23 def detectCapitalUse(self, word: str) -> bool:
24 num = 0
25 size = len(word)
26
27 #Generating the number
28 for i in range(size):
29 num = num*10
30 if word[i].isupper():
31 num+=1
32 num = int(str(num),2)
33
34 #Checking if it matches any of the valid number
35 if num==(1<<(size-1)) or num==(0<<(size-1)) or num==((1<<size)-1):
36 return True
37 return False

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected