Duplicate Encoder
Function Name: encodeDuplicates
Description
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.
Requirements
- The function must account for capitalization, but duplicates are considered regardless of case.
- Input string will only contain alphabets and no spaces or special characters.
- Function should be case-insensitive when determining duplicates but should maintain the original casing in the returned string.
- Performance should be considered for strings up to a length of 10,000 characters.
Examples
If the function is passed 'Success', it should return ')())())' because 's' appears more than once, hence encoded as ')', and all other characters are unique in different cases and are encoded as '('.If the function is passed 'Hello World', it should return '((()())())' despite ignoring the space character and being case-insensitive.
Links
Anagram Detector
Sun Aug 04 2024
An anagram is a word or phrase that's formed by rearranging the letters of another word or phrase. For example, 'listen' is an anagram of 'silent'.Write a function 'areAnagrams' that takes two strings and returns a boolean indicating whether or not they are anagrams of each other.The comparison should be case-insensitive and should disregard any non-alphabetical characters.The function should focus on performance for larger strings.
Merge Time Intervals
Tue Aug 06 2024
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