Manafall Daily Quest

Sequential Range Merge

Function Name: mergeSequentialRanges

Description

Write a function named 'mergeSequentialRanges' that takes an array of ranges and merges all sequential and overlapping intervals. Each range is represented as an array with two numbers, indicating the start and end of the range, inclusive. The function should return an array of the merged ranges in ascending order without any overlapping or sequential intervals.

Requirements

  • The 'mergeSequentialRanges' function must take one parameter: an array of ranges.
  • Ranges must be sorted in increasing order by their start point before merging.
  • The function should handle overlapping and directly sequential ranges by combining them into a single range.
  • The output must be a list of consolidated ranges with no duplicates or overlaps.
  • Assume each range within the array is valid and consists of two integers where the first is less than or equal to the second.
  • The function should effectively handle an empty array input by returning an empty array.

Examples

Example 1: mergeSequentialRanges([[1,3],[2,4]]) should return [[1,4]]Example 2: mergeSequentialRanges([[1,2],[3,4],[5,6]]) should return [[1,6]]Example 3: mergeSequentialRanges([]) should return []

Links

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

Anagram Validator

Tue Jul 23 2024

Create a function named `isAnagram` that determines whether two input strings are anagrams of each other.An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all original letters exactly once.For example, 'listen' is an anagram of 'silent'.The comparison should ignore spaces, punctuation, and should be case-insensitive.The function should return a boolean value.

Prev Quest

Clock Angle Calculator

Thu Jul 25 2024

Write a function named `findClockAngle` that calculates the smaller angle between the hour and minute hands on a traditional 12-hour analogue clock. The function should take two integer parameters, representing the hour and the minute, and return the smaller angle in degrees as an integer. If there are two possible angles (which could happen at times like 6:00), the function should return the smaller of the two. The function must handle cases where the hour is greater than 12 or less than 1, or where the minutes are greater than 59 or less than 0 by adjusting them to the correct values that would appear on a clock.

Next Quest