跳到主要内容

935.骑士拨号器

链接:935.骑士拨号器
难度:Medium
标签:动态规划
简介:你可以将骑士放置在任何数字单元格上,然后你应该执行 n - 1 次移动来获得长度为 n 的号码。所有的跳跃应该是有效的骑士跳跃。

题解 1 - python

  • 编辑时间:2024-12-10
  • 执行用时:59ms
  • 内存消耗:27.67MB
  • 编程语言:python
  • 解法介绍:dfs
class Solution:
def squareIsWhite(self, coordinates: str) -> bool:
return bool((ord(coordinates[0]) - ord('a')) % 2 + int(coordinates[1]) % 2 - 1)