peterschussheim
9/4/2016 - 3:53 PM

Sets

Sets

const longest = (s1, s2) => [...new Set(s1 + s2)].sort().join('') ///Create a function that accepts two strings s1 and s2, that returns a new string that is sorted and as long as possible, only using unique letters from s1 and s2.

a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"

longest(a, b)

Sets

This Gist was automatically created by Carbide, a free online programming environment.

You can view a live, interactive version of this Gist here.