题目链接:942. 增减字符串匹配
模拟。
from typing import List
class Solution:
def diStringMatch(self, s: str) -> List[int]:
l, h, n, ret = 0, len(s), len(s), []
for ch in s:
if ch == 'I':
ret.append(l)
l += 1
else:
ret.append(h)
h -= 1
ret.append(l)
return ret