Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean regularBracketSequence1(String str) {
- System.out.println(str);
- if(str.length()%2 != 0){
- return false;
- }
- if(str.length()>= 4){
- System.out.println("This was ran");
- for(int i=0; i<str.length()-1; ++i){
- if(str.charAt(i)=='('){
- if(str.charAt(i+1)==')'){
- if(i==0){
- String recStr= str.substring(i+2, str.length());
- regularBracketSequence1(recStr);
- }
- else{
- String recStr= str.substring(0,i)+ str.substring(i+2, str.length());
- regularBracketSequence1(recStr);
- }
- }
- }
- }
- }
- if(str.equals("()")){
- return true;
- }
- else return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement