Cho chuỗi s, kiểm tra xem có chứa tất cả 26 chữ cái tiếng Anh ít nhất một lần không.
Ví dụ
Đầu vào: "The grumpy wizards make toxic brew, for the evil queen and Jack".
Đầu ra: True.
Thuật toán
- Chuyển
sthành chữ thường. - Kiểm tra từng chữ cái trong
string.ascii_lowercasecó trongskhông. - Nếu thiếu bất kỳ chữ cái nào, trả về
False. - Trả về
True.
Mã nguồn Python
import string
class Solution:
def solve(self, s):
s = s.lower()
for i in string.ascii_lowercase:
if i not in s:
return False
return True
s = "The grumpy wizards make toxic brew, for the evil queen and Jack"
ob = Solution()
print(ob.solve(s))
Đầu vào / Đầu ra
Input: "The grumpy wizards make toxic brew, for the evil queen and Jack"
Output: True