Question: package Problem 2 ; public class ValidParentheses { / / do not change signature ( function name, parameters, return type ) public static boolean isValid

package Problem2;
public class ValidParentheses {
// do not change signature (function name, parameters, return type)
public static boolean isValid(String str){
// TODO: your code here for parameter check
// do not use any array.
Stack stack = new ArrayStack<>(500); // must use this ArrayStack from problem 1
// TODO: your code here
return false; // TODO: replace this with your code
}
}public void testValidParentheses(){
String[] inputs ={
"(}",
"{}()",
")[](",
"",
"[]{}()",
"[[{{}}]]()",
"[()]{",
"[]({})",
"xx",
"[[x]]",
"[x",
null
};
boolean[] expect ={false, true, false, true, true, true, false, true, false, false, false, true};
for (int i =0; i < inputs.length; i++){
boolean actual = isValid(inputs[i]);
System.out.print(expect);
//assertEquals(expect[i], actual, "case "+ i);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!