Questions tagged [balanced-delimiters]
When delimiters (a character or sequence marking the beginning, end, or boundary of a unit of data) are correctly placed (often in pairs) within a sequence or sequences of data.
76 questions
44
votes
2
answers
40k
views
Balanced parentheses
Given an expression string exp, write a program to examine whether the
pairs and the orders of
"{","}","(",")","[","]"
are correct in exp.
For example,...
30
votes
6
answers
72k
views
Checking for balanced brackets in Python
I'm solving HackerRank "Stacks: Balanced Brackets" in Python.
A bracket is considered to be any one of the following characters: (,
...
28
votes
6
answers
28k
views
Validating opening and closing bracket pairs
I have refactored one of my old homework assignments (mainly to utilize std::stack and some C++11), and I'm still having trouble making it less repetitive.
It ...
22
votes
7
answers
33k
views
Check for balanced parentheses
I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" ...
10
votes
5
answers
2k
views
Detecting balanced parentheses
Objective:
Given a string s containing '(', ')', '{', '}', '[', ']' (and other
characters), determine if the input string is valid.
An input string is valid if:
...
10
votes
1
answer
3k
views
Check for balanced brackets in JavaScript
Rules: You should create a function that receives a string with brackets, parentheses, or curly brackets, an example:
test('{A}')
The function must check that the ...
9
votes
4
answers
4k
views
Checking for parentheses balance in C
A recent assignment asks me to create a program that checks for parentheses balance in a given string. As I can't find any duplicate questions that have code written in C, I decided to post another ...
9
votes
2
answers
2k
views
A counterexample in balanced parentheses
In this program I had to analyse if the parenthesis given are well balanced. For instance, input (()) is correct and input ())(()...
9
votes
2
answers
5k
views
Balanced parentheses using standard C++
Here is a small program for checking if the parentheses are balanced or not. I am new to the standard library, and this is my first program. How can I improve it?
Any kind of modifications or ...
8
votes
4
answers
5k
views
Balanced Parentheses checker in Python
I'd appreciate feedback on the code itself (style, performance optimization (both space and time)), and also on the algorithm (because I think this is typically implemented using a stack).
The ...
8
votes
2
answers
8k
views
Balance braces method
This is a continuation of this question, at least the first part of that question.
I want to check if everything in the new code is right or if there are other way to make it better.
Exercise
The <...
8
votes
1
answer
128
views
Parenthesis-realigning program
This is my code for an assignment. The task is to take a user input in form of a sequence of parenthesis' followed by an E to mark its end and determine whether it is a correct sequence (as an example ...
7
votes
3
answers
6k
views
Checking for balanced parentheses
I wrote a method to check if each parenthesis in a string is closed. It should take into account the order in which a parenthesis is presented, e.g. "hello)goodbye(" should return false even though ...
7
votes
2
answers
6k
views
Looping through a string finding nested brackets
So I've been trying to check through a string, looping for, [ (start) and ] (end).
In this, I also have to check for nested ...
7
votes
4
answers
2k
views
Balanced braces
I wanted to write a JavaScript function that checked for balanced braces. I'd be grateful for any feedback on correctness and style.
...