Leetcode 979 Solution
This article provides solution to leetcode question 979 (di-string-match)
Access this page by simply typing in "lcs 979" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/di-string-match
Solution
class Solution:
def diStringMatch(self, S: str) -> List[int]:
l = 0
r = len(S)
i = 0
ans = []
while l < r:
if S[i] == 'I':
ans.append(l)
l += 1
else:
ans.append(r)
r -= 1
i += 1
ans.append(l)
return ans