Manafall Daily Quest

Simple Time Formatter

Function Name: formatTo24HourClock

Description

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.

Requirements

  • The input string will be in the format 'HH:MM AM' or 'HH:MM PM', where 'HH' can be '12' or '01' to '11', and 'MM' can be any two digits ranging from '00' to '59'.
  • The function must handle the transition from '12:00 AM' to '00:00', the start of a new day.
  • The function must also handle the transition from '11:59 PM' to '23:59', the end of the day.
  • You cannot use any date/time parsing libraries or built-in functions that automatically perform the conversion. You need to manually parse the string and perform the conversion.
  • Invalid input strings should return 'Invalid time format'.

Examples

formatTo24HourClock('02:15 PM') // should return '14:15'formatTo24HourClock('12:10 AM') // should return '00:10'formatTo24HourClock('07:45 AM') // should return '07:45'formatTo24HourClock('12:30 PM') // should return '12:30'formatTo24HourClock('00:00 AM') // should return 'Invalid time format'

Links

https://en.wikipedia.org/wiki/12-hour_clockhttps://en.wikipedia.org/wiki/24-hour_clock

Circular Queue Implementation

Sat Sep 21 2024

Implement a Circular Queue data structure using an array. The circular queue should support the following operations: enqueue, dequeue, peek, and isEmpty.The enqueue operation should add an item to the back of the queue if there is space. If the queue is full, it should return 'Queue Full'.The dequeue operation should remove an item from the front of the queue and return it. If the queue is empty, it should return 'Queue Empty'.The peek operation should return the item at the front of the queue without removing it. If the queue is empty, it should return 'Queue Empty'.The isEmpty operation should check if the queue is empty and return a boolean value.

Prev Quest

Balance Brackets

Mon Sep 23 2024

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.

Next Quest