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
This code is not what it seems...
Implementation of several common methods of LinkedList
Street light
Given two sorted arrays, merge them such that the elements are not repeated
Wenfeng Ou
String Class Methods
"encryption"
1.7
"Naive" recursion vs. Dynamic Programming
kth smallest element