Advertisement
Guest User

Untitled

a guest
Aug 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. boolean regularBracketSequence1(String str) {
  2.     System.out.println(str);
  3.     if(str.length()%2 != 0){
  4.         return false;
  5.     }
  6.     if(str.length()>= 4){
  7.         System.out.println("This was ran");
  8.         for(int i=0; i<str.length()-1; ++i){
  9.             if(str.charAt(i)=='('){
  10.                 if(str.charAt(i+1)==')'){
  11.                     if(i==0){
  12.                         String recStr= str.substring(i+2, str.length());
  13.                         regularBracketSequence1(recStr);
  14.                     }
  15.                     else{
  16.                         String recStr= str.substring(0,i)+ str.substring(i+2, str.length());
  17.                         regularBracketSequence1(recStr);
  18.                     }
  19.                 }
  20.             }
  21.         }
  22.     }
  23.     if(str.equals("()")){
  24.         return true;
  25.     }
  26.     else return false;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement