MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / ispar

Method ispar

BalancedParanthesis.java:27–45  ·  view source on GitHub ↗
(String x)

Source from the content-addressed store, hash-verified

25 }
26
27 static boolean ispar(String x)
28 {
29 // add your code here
30 Stack<Character> stack = new Stack<Character>();
31 for(int i=0;i<x.length();i++)
32 {
33 if(opening(x.charAt(i)))
34 {
35 stack.push(x.charAt(i));
36 }
37 else
38 {
39 if(stack.isEmpty()) return false;
40 if(!Matches(stack.peek(),x.charAt(i))) return false;
41 stack.pop();
42 }
43 }
44 return stack.isEmpty();
45 }
46}

Callers

nothing calls this directly

Calls 5

openingMethod · 0.95
MatchesMethod · 0.95
pushMethod · 0.80
popMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected