private Stack PushOpenBracketIntoBracketStack(Stack bracketStack, Bracket openBracket)
        {
            var output = bracketStack;

            output.Push(openBracket);
            return(output);
        }
        private Stack CreateMissMatchBracketStack(string str)
        {
            var bracketStack = new Stack();

            for (var i = 0; i <= str.ToCharArray().Length - 1; i++)
            {
                var s       = str.ToCharArray()[i];
                var bracket = new Bracket(s, i);
                bracketStack = PushBracketIntoBracketStack(bracketStack, bracket);
            }
            return(bracketStack);
        }
        private Stack PushCloseBracketIntoBracketStack(Stack bracketStack, Bracket closeBracket)
        {
            var output = bracketStack;

            if (HasMatchOpenBracketInStack(bracketStack, closeBracket))
            {
                output.Pop();
            }
            else
            {
                output.Push(closeBracket);
            }
            return(output);
        }
        private Stack PushBracketIntoBracketStack(Stack bracketStack, Bracket bracket)
        {
            var output           = bracketStack;
            var bracketCharacter = bracket.Character;

            if (IsOpenBracket(bracketCharacter))
            {
                output = PushOpenBracketIntoBracketStack(bracketStack, bracket);
            }
            if (IsCloseBracket(bracketCharacter))
            {
                output = PushCloseBracketIntoBracketStack(bracketStack, bracket);
            }
            return(output);
        }
        private bool HasMatchOpenBracketInStack(Stack bracketStack, Bracket closeBracket)
        {
            if (bracketStack.Count == 0)
            {
                return(false);
            }

            var openBracketInStack = (Bracket)bracketStack.Peek();

            if (IsBracketMatch(openBracketInStack.Character, closeBracket.Character))
            {
                return(true);
            }

            return(false);
        }