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
5
votes
2
answers
971
views
Find redundant braces in an input string
I am solving interview questions from InterviewBit site.
Problem : Write a program to validate if the input string has redundant braces
Return 0/1 :
...
3
votes
2
answers
940
views
Using the stack algorithm for parenthesis matching
I have used Stacks to check for brackets mismatch. (Parentheses matching problem using Stack algorithm)
Any suggestions on how to improve the code?
I have tried various examples and it works ...
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:
...
2
votes
2
answers
4k
views
Bracket matcher in Python
I would like to receive feedback on my coding interview for the following problem:
Bracket Match
A string of brackets is considered correctly matched if every opening
bracket in the string ...
7
votes
5
answers
8k
views
Validate that brackets are balanced
I've done a test for a job (which I failed) and I'd like to know in which ways my code could've been better.
Here are the questions and my answers, it's not very long.
1) Make a program that checks ...
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 ...
2
votes
3
answers
1k
views
Check if parentheses are balanced using a stack implemented with a linked list
Problem: Stacks can be used to check whether the given expression has balanced symbols. This algorithm is very useful in compilers. Each time the parser reads one character at a time. If the character ...
2
votes
1
answer
286
views
Leetcode problem: minimum removal to make valid parentheses
I was working on this problem on leetcode
Question
Your task is to remove the minimum number of parentheses ( '(' or
')', in any positions ) so that the resulting parentheses string is
valid and ...
2
votes
1
answer
209
views
follow-up - Checking Nested Bracket Levels in Strings Programming Challenge
A follow-up to this question, this post improves on test case issues.
To restate problem parameters, a given string S is considered closed if it:
Has a matching ...
3
votes
2
answers
238
views
Programming Challenge - Capturing Bracket Levels
I don't have a formal description for this problem, but here are the parameters:
Given a string S check that each opening bracket has a matching closing bracket.
...
5
votes
3
answers
6k
views
Balanced parenthesis in Ruby
I'm solving the "Balanced Parenthesis" problem in Ruby, and I came up with this solution.
...
3
votes
1
answer
558
views
Generate valid combinations of parentheses
Playing on leetcode coding problem: "Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses."
I realized that my understanding of Python was ...
7
votes
1
answer
4k
views
Given a string containing just parentheses, determine if the input string is valid
The task
is taken from leetcode
Given a string containing just the characters '(', ')', '{', '}', '['
and ']', determine if the input string is valid.
An input string is valid if:
...
5
votes
2
answers
5k
views
C# code to check balanced brackets in a string
The code works, at least against the unit tests. But I would like input on how to refactor it. Or also maybe a way to do this without using temporary lists? I also have some special checks, like if ...
4
votes
2
answers
260
views
Retrieving top-level opening and closing sequences from a Python string
The problem I'm solving is a more complex version of pairing up opening and closing brackets.
Instead of matching only on ([{}]), I additionally need to match ...