Manafall Daily Quest

Balance Brackets

Function Name: balanceBrackets

Description

Write a function called balanceBrackets that takes a single string parameter consisting of different brackets (e.g., '(', ')', '[', ']', '{', '}') and returns a boolean indicating whether the brackets in the string are balanced. Brackets are considered to be balanced if every opening bracket has a corresponding closing bracket and the pairs of brackets are properly nested.

Requirements

  • The function should only consider the characters '(', ')', '[', ']', '{', and '}' and ignore all other characters.
  • The function should return true if the brackets are balanced and false otherwise.
  • An empty string should be considered as balanced.
  • You should not use any built-in functions for stack implementation. However, you can use lists to simulate the functionality of a stack.

Examples

Given the string '(a + b) + {[c * d]}', the output should be true.Given the string '((a + b)) + {(c * d)]', the output should be false.Given the string ')(', the output should be false.Given the string '', the output should be true.

Links

https://en.wikipedia.org/wiki/Dyck_language

Simple Time Formatter

Sun Sep 22 2024

Write a function that converts 12-hour time format to 24-hour format. The function will take a string representing the time as its parameter. It must return the converted time as a string in the format 'HH:MM', ensuring 'HH' and 'MM' are both two digits.

Prev Quest

Matrix Spiral Traversal

Tue Sep 24 2024

Write a function that takes an m x n 2D array (matrix) and returns a list of its elements in spiral order. Spiral order starts at the top-left corner of the matrix, proceeds to the right, and follows a clockwise pattern inward.The function should account for both rectangular and square matrices, and it should handle empty matrices as well, returning an empty list for the latter.

Next Quest