Manafall Daily Quest

Aggregate Event Times

Function Name: mergeTimeIntervals

Description

Write a function that takes a list of time intervals for various events, where each interval is represented as a pair of strings (start, end) in 24-hour 'HH:MM' format. The function should return a list of merged intervals if any two intervals overlap.

The input list can be unsorted and there might be multiple intervals overlapping. The merged intervals should be outputted in sorted order, without any overlapping.

Assume that time intervals are closed, meaning '10:00' - '12:00' and '12:00' - '13:00' do overlap at '12:00'.

Requirements

  • The function should take a single parameter: a list of time interval tuples, where each interval is represented by a pair of strings.
  • The returned list should consist of merged intervals represented as tuples, sorted by their start times.
  • If an interval is contained entirely within another, it should only appear as part of the merged interval.
  • The function should handle edge cases, such as the start time being the same as the end time of the previous interval.
  • Assume that all given times are valid and within the same day.

Examples

Given a list of intervals: [('09:00', '11:30'), ('11:20', '13:00'), ('14:00', '15:00'), ('10:30', '12:00')]The function should return: [('09:00', '13:00'), ('14:00', '15:00')]

Binary Tree Right Side View

Fri Nov 08 2024

Write a function that takes the root node of a binary tree and returns the value of the nodes visible when the tree is viewed from the right side. This is done by returning the rightmost node at each level of the tree. If no rightmost node is present at any level (such as in a left-leaning tree), the function should return the last node in that level's traversal.

Prev Quest

Minimal Swaps to Ascend

Sun Nov 10 2024

Write a function that calculates the minimum number of swaps required to sort an array of unique integers in ascending order. The function should perform this calculation without actually sorting the array.Each swap can only exchange two elements. Assume that the input array does not contain any duplicate values and contains at least two numbers.

Next Quest