Skip to content

Commit a135ead

Browse files
authored
Create 4061. Minimum Queen Moves to Reach Target.py
1 parent 6a635d6 commit a135ead

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
최대 2번 움직입니다
6+
0번: 같은 점
7+
1번: 같은 가로/세로/대각
8+
2번: 위 제외 나머지
9+
10+
2. 시간복잡도 :
11+
O(1)
12+
13+
3. 자료구조/알고리즘 :
14+
-
15+
16+
'''
17+
class Solution:
18+
def minQueenMoves(self, source: list[int], target: list[int]) -> int:
19+
s1, s2 = source
20+
e1, e2 = target
21+
22+
if s1 == e1 and s2 ==e2:
23+
return 0
24+
if s1 == e1 or s2 == e2 or abs(s1-e1) == abs(s2-e2):
25+
return 1
26+
return 2
27+
28+

0 commit comments

Comments
 (0)