Post

leetcode(리트코드)-1812 Determine Color of a Chessboard Square(PYTHON)

leetcode 1812 - Determine Color of a Chessboard Square 문제입니다.

1. 문제

https://leetcode.com/problems/determine-color-of-a-chessboard-square/


2. Input , Output


3. 분류 및 난이도

Eazy 난이도 문제입니다.


4. 문제 해석

  • coordinates는 어떠한 열과 행에 대한 이름입니다.
  • 그 열과 행에 해당되는 부분이 Black인지 White인지 확인하여 black이면 False를 리턴 White는 True를 리턴하세요.

5. code

코드설명

python

1
2
3
4
class Solution:
    def squareIsWhite(self, coordinates: str) -> bool:
        res = (ord(coordinates[0]) - 97) + int(coordinates[1])
        return False if res%2 == 1 else True

6. 결과 및 후기, 개선점

필요시 c++로 작성해드립니다.

모르겟으면 댓글 부탁드립니다.

This post is licensed under CC BY 4.0 by the author.