- Notifications
You must be signed in to change notification settings - Fork2.4k
Closed
Description
Bug Report forhttps://neetcode.io/problems/minimum-remove-to-make-valid-parentheses
Tried to submit a solution for this problem but an alternative output which should be an acceptable answer isn't accepted
class Solution: def minRemoveToMakeValid(self, s: str) -> str: l = list(s) st = [] for i in range(len(l)): if l[i] == '(': st.append(i) elif l[i] == ')': if st: st.pop() else: l[i] = '' while st: i = st.pop() l[i] = '' return ''.join(l)
Output - (((((dd(())a)())bbb)))()cccc
But only acceptable output is
((((((dd(())a)())bbb))))cccc
PS same solution works on Leetcode with the same input and code
Metadata
Metadata
Assignees
Labels
No labels