Skip to content

Bug Report for valid-parenthesis-string; Missing Testcase #4302

Open
@rajavivek

Description

@rajavivek

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions