Valid Parenthesis String (LeetCode 678)The problem You get a string of , and . Each can act as , as , or as nothing…