Created
September 3, 2023 11:06
-
-
Save ChousinRahit/95510c3383dc589d58315f02d1f9e5d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Split String by Identical Characters | |
// Create a function that splits a string into an array of identical clusters. | |
// Examples | |
// splitGroups("555") ➞ ["555"] | |
// splitGroups("5556667788") ➞ ["555", "666", "77", "88"] | |
// splitGroups("aaabbbaabbab") ➞ ["aaa", "bbb", "aa", "bb", "a", "b"] | |
// splitGroups("abbbcc88999&&!!!_") ➞ ["a", "bbb", "cc", "88", "999", "&&", "!!!", "_"] | |
// Notes | |
// 1 - Each cluster should only have one unique character. | |
// 2 - The resulting array should be in the same order as the input string. | |
// 3 - Should work with letters, numbers and other characters. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment