using System.Collections.Generic;
private static bool CheckInput(string input)
Stack<char> tempStack = new Stack<char>();
foreach (char c in input)
if (c == '[' || c == '{' || c == '(')
else if (c == ']' || c == '}' || c == ')')
char prev = tempStack.Pop();
if ((c == ']' && prev != '[') || (c == ')' && prev != '(') || (c == '}' && prev != '{'))
public static void Main()
Console.WriteLine(CheckInput("[{{(())[())}}]") ? "Wrong" : "Correct");
Console.WriteLine(CheckInput("[{{(())$())}}]") ? "Wrong" : "Correct");
Console.WriteLine(CheckInput("") ? "Correct" : "Wrong");
Console.WriteLine(CheckInput(null) ? "Wrong" : "Correct");