Created
February 19, 2017 12:31
-
-
Save mchernyavskaya/e64108cdf339e0c46e9145d91ce53a62 to your computer and use it in GitHub Desktop.
Check matching brackets - solution without a stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Groups{ | |
public static boolean groupCheck(String s) { | |
int len; | |
do { | |
len = s.length(); | |
s = s.replace("()", ""); | |
s = s.replace("{}", ""); | |
s = s.replace("[]", ""); | |
} while (len != s.length()); | |
return s.length() == 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment