Open
Description
Bug Report for https://neetcode.io/problems/valid-parenthesis-string
Missing Testcase:
s="()()()()())))"
my code is accepted by System but it should fail for this testcase
myCode:
class Solution {
private boolean h(char[] arr, int n,int count){
if (n<0) return count == 0;
if (arr[n] == '(') count += 1;
else if (arr[n] == ')') count -= 1;
if(count > 0) return false;
if (arr[n] == '*') return h(arr,n-1,count) || h(arr,n-1,count-1) || h(arr,n-1,count+1);
return h(arr, n-1, count);
}
public boolean checkValidString(String s) {
return h(s.toCharArray(), s.length()-1, 0);
}
}
Metadata
Metadata
Assignees
Labels
No labels