Skip to content

Instantly share code, notes, and snippets.

@ChousinRahit
Created September 3, 2023 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChousinRahit/95510c3383dc589d58315f02d1f9e5d0 to your computer and use it in GitHub Desktop.
Save ChousinRahit/95510c3383dc589d58315f02d1f9e5d0 to your computer and use it in GitHub Desktop.
// 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