Saturday, June 24, 2023

Unmix My Strings

Unmix My Strings


lPaeesh le pemu mnxit ehess rtnisg! Oh, sorry, that was supposed to say: Please help me unmix these strings! Somehow my strings have all become mixed up; every pair of characters has been swapped. Help me undo this so I can understand my strings again. 
 unmix("123456") ➞ "214365" 
 unmix("hTsii s aimex dpus rtni.g") ➞ "This is a mixed up string." 
 unmix("badce") ➞ "abcde" 


Input: hTsii s aimex dpus rtni.g, Output: This is a mixed up string. 
Input: 214365, Output: 123456 
Input: badce, Output: abcde 



Question Reference: https://edabit.com/challenge/XRAGxXj4KtakkvD3F

Largest Gap

Given an array of integers, return the largest gap between the sorted elements of the array.

For example, consider the array:

[9, 4, 26, 26, 0, 0, 5, 20, 6, 25, 5] ... in which, after sorting, the array becomes:

[0, 0, 4, 5, 5, 6, 9, 20, 25, 26, 26] ... so that we now see that the largest gap in the array is between 9 and 20 which is 11.