Commit 221adbec authored by Mike John Herter's avatar Mike John Herter

Delete sort_and_remove_duplicated_characters.js

parent 2adc6b7e
function longest(str1, str2) {
newstring=str1+str2;
newarray=newstring.split("").sort().join("")
let result=""
for (let i = 0; i < newarray.length; i++) {
if (result.indexOf(newarray[i]) === -1) {
result+=newarray[i]
}
}
return result
}
console.log(longest('abcccaa', 'acddddffzzz'))// => 'abcdfz'
a = 'xyaabbbccccdefww'
b = 'xxxxyyyyabklmopq'
console.log(longest(a, b)) // => 'abcdefklmopqwxy'
a = 'abcdefghijklmnopqrstuvwxyz'
console.log(longest(a, a)) // => 'abcdefghijklmnopqrstuvwxyz'
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment