Opening your workspace…
Workspace/Coding room
Opening your workspace…
You go looking for the office supply closet and find the Backrooms. Someone has pinned a note to the yellow wallpaper. “If you find the supply closet, we need more pins.”
Your route is recorded in the string text. Read it from left to right, starting outside the rooms. Each (, [ or { takes you through a doorway into another room. To leave a room entered through (, use ). For [ use ], and for { use }.
You can only leave the most recently entered room you are still inside. Return false if you encounter a return doorway of the wrong kind or try to leave when you are already outside. After the last mark, return true if you are back outside and false if you are still in a room. An empty route returns true.
"{[()]}"OutputtrueEach bracket is closed by its own type, starting with the innermost pair.
"([)]"OutputfalseThe round bracket is closed while the square bracket inside it is still open.
The bracket that was opened most recently has to be the first one closed. Which data structure hands items back in that order?
/** @param {string} text * @returns {boolean} */ function solve(text) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.
"{[()]}"true