Manafall Daily Quest

Balanced Parentheses

Function Name: isBalanced

Description

Write a function that takes a string containing only '(', ')', '{', '}', '[' and ']', determines if the input string is valid. An input string is valid if:

1. Open brackets must be closed by the same type of brackets.

2. Open brackets must be closed in the correct order.

3. An empty string is considered balanced.

Requirements

  • The function must be named 'isBalanced'.
  • The 'isBalanced' function must take a single parameter: a string containing only the characters: '(', ')', '{', '}', '[' and ']'.
  • The function must return a boolean value: true if the string is balanced, false otherwise.
  • Do not use regular expressions to solve this challenge.
  • Function should run in O(n) time, where n is the length of the string.

Examples

Example 1: isBalanced('(){}[]') should return true.Example 2: isBalanced('([)]') should return false.Example 3: isBalanced('{[()]}') should return true.Example 4: isBalanced('') should return true.Example 5: isBalanced('({[]}()') should return false.

Links

https://en.wikipedia.org/wiki/Brackethttps://en.wikipedia.org/wiki/Stack_(abstract_data_type)

Simple Time Conversion

Wed Aug 28 2024

Write a function that converts 12-hour time format to 24-hour time format.The function will take a string representing the time in 12-hour format as input, e.g., '02:15PM' or '11:45AM'.It should return a string representing the time in 24-hour format, e.g., '14:15' or '11:45'.The input string will always be a valid time with uppercase 'AM' or 'PM'.

Prev Quest

Garden Watering Scheduler

Fri Aug 30 2024

Write a function to to help schedule garden watering times throughout a given week.The garden requires watering every other day, starting on Monday, at the same time each scheduled day.You should output a schedule that lists the day of the week and the corresponding time for watering.The function must take two parameters: the start time for watering on the first day (a string in 'HH:MM' 24-hour format), and a positive integer representing the number of weeks to schedule.

Next Quest