本文共 404 字,大约阅读时间需要 1 分钟。
原题指路
时间复杂度: O ( 1 ) O(1) O(1)
空间复杂度: O ( 1 ) O(1) O(1)class Solution: def squareIsWhite(self, coordinates: str) -> bool: dict = { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8} res = dict[coordinates[0]] + int(coordinates[1]) if res % 2: return True else: return False
转载地址:http://cvdg.baihongyu.com/