forked from sammorozov/1337Code_tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1436. Destination City.py
63 lines (36 loc) · 951 Bytes
/
1436. Destination City.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from typing import *
class Solution:
def destCity(self, paths: List[List[str]]) -> str:
cnt = 0
for pair in paths:
second_sity = pair[1]
for pair_2 in paths:
if pair_2[0] == second_sity:
break
else:
cnt +=1
if cnt == len(paths):
return second_sity
else:
cnt = 0
print(Solution().destCity(paths = [["B","C"],["D","B"],["C","A"]]))
'''
there is some code for show how set works and how zip works
'''
print('^the answer^_______________________')
a = {2, 3, 4}
b = {1, 2, 3, 4}
c = {1, 2, 3, 4}
d = {2, 3, 4}
print(a - b)
print(c - d)
print('_______________')
paths = [["B","C"],["D","B"],["C","A"]]
frm = zip(*paths)
print(list(frm))
print(*paths)
# print(to)
frm, where = zip(*paths)
print('________________')
print(frm)
print(where)