Skip to content

Commit c68c110

Browse files
committed
msic
1 parent 5e36c32 commit c68c110

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

my-submissions/e942 v1.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def diStringMatch(self, s: str) -> List[int]:
3+
minn, maxx = 0, 0
4+
output = [0]
5+
for c in s :
6+
if c == 'I' :
7+
output.append(maxx := maxx + 1)
8+
else :
9+
output.append(minn := minn - 1)
10+
return [x - minn for x in output]

my-submissions/e942 v2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Solution:
2+
def diStringMatch(self, s: str) -> List[int]:
3+
minn, maxx = 0, 0
4+
output = [0] + [(maxx := maxx + 1) if c == 'I' else (minn := minn - 1) for c in s]
5+
return [x - minn for x in output]

0 commit comments

Comments
 (0)