hacker rank 33th java problem solution(JAVA STACK)
33. JAVA STACK
import java.util.*;
class Solution{
public static void main(String []argh)
{
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String input=sc.next();
while(input.length() != (input = input.replaceAll("\\(\\)|\\[\\]|\\{\\}", "")).length());
System.out.println(input.isEmpty());
}
}
}
Comments