Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Balanced brackets

    Balanced brackets

    Easystackstring

    s contains only the brackets ()[]{}. Return true if every bracket opened is closed by the same type in the right order.

    Example 1

    Input:  s = "()"
    Output: true

    Example 2

    Input:  s = "()[]{}"
    Output: true

    Example 3

    Input:  s = "(]"
    Output: false

    Constraints

    • 0 ≤ s.length ≤ 10⁴

    Submit checks your solution against 10 tests, including hidden ones.

    /**
     * @param {string} s
     * @return {bool}
     */
    function isValidBrackets(s) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.