Manafall Daily Quest

Merge Time Intervals

Function Name: mergeIntervals

Description

Write a function 'mergeIntervals' that takes a list of time intervals, where each interval is represented as a pair of integers (start, end), and merges overlapping intervals.

The intervals must be returned in ascending order and without overlaps.

If an interval is contained within another, they should be merged into a single interval.

The function should handle an arbitrary number of intervals

Requirements

  • The function should take a single argument, which is a list of pairs of integers. Each pair represents a time interval.
  • It should return a list of merged intervals sorted by the start times.
  • Intervals that are adjacent but not overlapping should not be merged.
  • The function should handle cases with no intervals, one interval, and many intervals.

Examples

Given intervals: [(1, 3), (5, 8), (4, 10), (20, 25)]Your function should return: [(1, 3), (4, 10), (20, 25)]

Links

https://en.wikipedia.org/wiki/Interval_(mathematics)

Duplicate Encoder

Mon Aug 05 2024

Write a function named 'encodeDuplicates' that takes a single string as its parameter.The function will transform the string into a new string where each lowercase character is replaced with '(' if that character appears only once in the original string, or with ')' if that character appears more than once in the original string.Ignore capitalization when determining if a character is a duplicate.The function should return the newly encoded string.

Prev Quest

Balanced Subarrays

Wed Aug 07 2024

The goal of this challenge is to write a function named 'findBalancedSubarrays' that takes in an array of integers and returns the total number of contiguous subarrays where the sum of elements on the left is equal to the sum of elements on the right.A subarray consists of one or more consecutive elements of the array. For subarrays with an odd number of elements, the middle element should be considered as belonging to neither side.

Next Quest