You are viewing a single comment's thread. Return to all comments →
input = input.replaceAll("\\(\\)|\\[\\]|\\{\\}", ""))
This will replace ()[]{} with "" , making input length lesser than earlier
Now this *input.length()* will be the length of ()[]{} removed input
So, if you start with ([{}])...
input.length() is 6 , after input.replaceAll(..), *input* will be '([])' , and its length is 4 where *6!=4*,so while loop continues
Seems like cookies are disabled on this browser, please enable them to open this website
Java Stack
You are viewing a single comment's thread. Return to all comments →
This will replace ()[]{} with "" , making input length lesser than earlier
Now this *input.length()* will be the length of ()[]{} removed input
So, if you start with ([{}])...
input.length() is 6 , after input.replaceAll(..), *input* will be '([])' , and its length is 4 where *6!=4*,so while loop continues