Manafall Daily Quest

Unique Character Mapping

Function Name: isIsomorphic

Description

Create a function named isIsomorphic that takes two strings and determines if they are isomorphic. Two strings are isomorphic if the characters in the first string can be replaced to get the second string. The replacement must be consistent for all occurrences of a character and no two characters may map to the same character, but a character may map to itself.

Requirements

  • The function should take two arguments, both of them strings.
  • The function should return a boolean true if the strings are isomorphic, otherwise false.
  • The inputs can be assumed to contain only lower-case alphabetic characters.
  • All strings are of equal length.
  • You should not use any third-party libraries or modules.
  • The goal is to solve this task with O(n) time complexity, where n is the length of the strings.

Examples

isIsomorphic('egg', 'add') should return true because we can map e -> a, g -> d.isIsomorphic('foo', 'bar') should return false because 'o' cannot map to both 'a' and 'r'.isIsomorphic('paper', 'title') should return true because we can map p -> t, a -> i, e -> l, r -> e.

Links

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

Even Odd Partition

Sun Dec 22 2024

Create a function named 'partitionEvenOdd' which takes a list of integers as its only parameter.The function should partition the list into two separate lists: one containing all even numbers, the other containing all odd numbers.The function should then return a tuple of these two lists.The original ordering of the numbers in the input list should be preserved.

Prev Quest

Custom String Compression

Tue Dec 24 2024

Write a function that performs a basic string compression using the counts of consecutive repeated characters.For example, the string 'aabcccccaaa' would become 'a2b1c5a3'.If the compressed string is not smaller than the original string, your function should return the original string.The function should handle uppercase and lowercase letters separately, meaning 'Aa' should be compressed as 'A1a1'.

Next Quest