Created
March 22, 2016 20:58
-
-
Save brandonbarringer/0830ce84253f8f04ce89 to your computer and use it in GitHub Desktop.
Expander
This file contains hidden or 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
/* | |
You are given a string s composed of letters and numbers, which was compressed with some algorithm. | |
Every letter in s is followed by a number (possibly with leading zeros), | |
which represents the number of times this letter occurs consecutively. For example, "aaaaaaaabbbbbbcc" | |
would be given as "a8b6c2". | |
*/ | |
Expand_It = (s, k) => s.split(/(\d+|\D+)/g).filter(n => !!n).map( (v, i, a) => v.repeat( a[i+1] ) ).sort().join("")[k-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment