protected function isCorrect(string $sentence): bool
    {
        $bracketsStack = [];
        $sentenceChars = str_split($sentence);
        $openBrackets = array_keys($this->brackets);
        foreach ($sentenceChars as $char) {
            if (in_array($char, $openBrackets)) {
                $bracketsStack[] = $this->brackets[$char];
                continue;
            }

            if (in_array($char, $this->brackets)) {
                $idx = array_search($char, $bracketsStack);
                if ($idx !== false) {
                    unset($bracketsStack[$idx]);
                    continue;
                }
                return false;
            }
        }

        return count($bracketsStack) === 0;
    }