-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path942.py
32 lines (32 loc) · 1.03 KB
/
942.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
__________________________________________________________________________________________________
sample 56 ms submission
class Solution:
def diStringMatch(self, S: str) -> List[int]:
top = len(S)
bottom = 0
total = []
for order in S:
if order == "I":
total.append(bottom)
bottom = bottom + 1
else:
total.append(top)
top = top - 1
total.append(top)
return total
__________________________________________________________________________________________________
sample 14064 kb submission
class Solution:
def diStringMatch(self, S: str) -> List[int]:
r = [0]
m = 0
M = 0
for s in S:
if s == 'D':
r.append(m - 1)
m -= 1
else:
r.append(M + 1)
M += 1
return [i + abs(m) for i in r]
__________________________________________________________________________________________________