Manafall Daily Quest

String Permutations

Function Name: generateStringPermutations

Description

In this challenge, you are required to write a function named 'generateStringPermutations' that takes a single string as an input parameter and returns all possible permutations of the characters in the string. A permutation is a re-arrangement of the elements of an ordered list. Each permutation should be unique, meaning if the string contains duplicate characters, permutations that are identical should be returned only once. The order of permutations in the returned collection does not matter.

Requirements

  • The function must take exactly one parameter: a string.
  • The function must return a collection (e.g., an array or list) containing all unique permutations of the string.
  • Assume that the string only contains English letters (both uppercase and lowercase) and has a maximum length of 8 characters.
  • Do not use any built-in permutation generation functions; implement the logic from scratch.
  • The time complexity should be taken into consideration as generating permutations can be computationally intensive.

Examples

Example 1: generateStringPermutations('abc') should return ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'].Example 2: generateStringPermutations('aab') should return ['aab', 'aba', 'baa']."Note: The order of the permutations in the output does not matter and may vary."

Links

https://en.wikipedia.org/wiki/Permutation

Matrix Spiral Traversal

Tue Sep 24 2024

Write a function that takes an m x n 2D array (matrix) and returns a list of its elements in spiral order. Spiral order starts at the top-left corner of the matrix, proceeds to the right, and follows a clockwise pattern inward.The function should account for both rectangular and square matrices, and it should handle empty matrices as well, returning an empty list for the latter.

Prev Quest

Merge Intervals

Thu Sep 26 2024

Write a function 'mergeIntervals' that given a list of intervals, merges all the overlapping intervals to produce a list that has only mutually exclusive intervals. The intervals are represented as pairs of integers.Each interval is provided as an array with two integers indicating the start and end. The end of each interval is always greater than or equal to the start.The function should return the merged intervals in ascending order starting with the interval with the lowest starting point.

Next Quest