There was an error while loading. Please reload this page.
1 parent bd6c829 commit fffb002Copy full SHA for fffb002
1 file changed
src/parentheseExo/Principale.java
@@ -19,9 +19,15 @@ public static boolean estParenthese(String phrase) {
19
stack.push("]");
20
}
21
22
- else if (phrase.charAt(i) == ')' && stack.peek().equals(")")) {
+ else if (phrase.charAt(i) == ')') {
23
+ if (!stack.peek().equals(")")) {
24
+ return false;
25
+ }
26
stack.pop();
- } else if (phrase.charAt(i) == ']' && stack.peek().equals("]")) {
27
+ } else if (phrase.charAt(i) == ']' ) {
28
+ if (!stack.peek().equals("]")) {
29
30
31
32
33
0 commit comments