Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 656 Bytes

File metadata and controls

22 lines (15 loc) · 656 Bytes

longestWord

Interview question of the issue #254 of rendezvous with cassidoo.

The Question

Given a string str and a set of words dict, find the longest word in dict that is a subsequence of str.

Example:

let str = "abppplee"
let dict = {"able", "ale", "apple", "bale", "kangaroo"}

$ longestWord(str, dict)
$ 'apple'
// "able" and "ale" also work, but are shorter than "apple"
// "bale" has all the right letters, but not in the right order

Installing & Running

Just pnpm i to install all dependencies and then pnpm t to run the tests!