-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path389.py
More file actions
27 lines (24 loc) · 966 Bytes
/
389.py
File metadata and controls
27 lines (24 loc) · 966 Bytes
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
__________________________________________________________________________________________________
sample 24 ms submission
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
import collections
c_s = collections.Counter(s)
c_t = collections.Counter(t)
key_s = set(c_s.keys())
key_t = set(c_t.keys())
if len(key_t-key_s):
return list(key_t-key_s)[0]
else:
for ks in key_s:
if c_s[ks] != c_t[ks]:
return ks
__________________________________________________________________________________________________
sample 12960 kb submission
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
code = 0
for ch in s+t:
code ^= ord(ch)
return chr(code)
__________________________________________________________________________________________________