Coder Social home page Coder Social logo

balanced-brackets-dc-web-career-040119's Introduction

Balanced Brackets

Problem

Given a string consisting only of the characters (, [, {, ), ], and }, write a function isBalanced() that returns a boolean that determines whether or not every open parentheses or bracket is paired correctly and is balanced.

Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and ().

A matching pair of brackets is not balanced if the set of brackets it encloses are not matched. For example, {[(])} is not balanced because the contents in between { and } are not balanced. The pair of square brackets encloses a single, unbalanced opening bracket, (, and the pair of parentheses encloses a single, unbalanced closing square bracket, ].

More examples:

isBalanced("()[]")
//true
isBalanced("([])")
//true
isBalanced("({)}")
//false
isBalanced("{[}")
//false

Process

Mainly, this is your chance to shine. This problem is hard, but one of the nice things about it is that it has many different solutions.

Use it as a mechanism to focus on process, and work with a partner, if you can. Think about this problem as a practice in breaking down problems, and knowing when to retreat from a potential solution. Remember from the last lesson to try to derive what was good and what did not work in your previous attempt, before moving onto a new attempt.

A couple small hints to get started: where are some examples where the solution becomes obvious. What can you learn from it. Ok that's enough.

Be self-aware about when your process. When is your process good, and when it is less successful? We are trying to be disciplined about developing good habits as much as anything else.

balanced-brackets-dc-web-career-040119's People

Contributors

7kingdavid7 avatar alpha-convert avatar annjohn avatar bhollan avatar jakebrady5 avatar jasonpaulso avatar jeffkatzy avatar jeffpwang avatar jonbf avatar pletcher avatar salsa-dude avatar smulligan85 avatar tejbans avatar thuyanduong-flatiron avatar victhevenot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.