Letters Formed from the Longest Word

Published by Helen Yu in

Write a function that returns true if all the strings in an array can be formed by using only the characters from the longest string.

Examples

canForm(["mast", "manifest", "met", "fan"]) ➞ true

canForm(["may", "master", "same", "reams"]) ➞ false

canForm(["may", "same", "reams", "mastery"]) ➞ true

Notes

There will only be one unique longest string.

Watch a quick demo on how Edabit works.