public static bool isExpressionValid(char[] array)
        {
            StackOperations stack = new StackOperations(array.Length);

            foreach (var item in array)
            {
                if (item == '{' || item == '[' || item == '(')
                {
                    stack.Push(item);
                }
                else
                {
                    if (stack.IsEmpty())
                    {
                        return(false);
                    }
                    if (!isParenthesesMatching(Convert.ToChar(stack.Pop()), item))
                    {
                        return(false);
                    }
                }
            }
            if (stack.IsEmpty())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 public GetMinimumInStack()
 {
     stack = new StackOperations(100);
 }