Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Brackets balancing
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { String input = "a(((b+c)+d)"; char[] c = input.toCharArray(); char[] x = new char[c.length]; int top=-1; for(int i=0;i<c.length;i++){ if(c[i] == '('){ top=top+1; x[top]=c[i]; } else if(c[i] == ')'){ top=top-1; } } if(top==-1){ System.out.println("Brackets are balanced"); } else System.out.println("Brackets are not balanced"); } }
run
|
edit
|
history
|
help
0
String Palindrome
MyBirdClass
add static
ArrayOperation
alphabet
Project Euler #2
jb11.0 threads tick tock 1.0
pass
1
Number to Words (Accenture)