Skip to content

Latest commit

 

History

History

274-combineStrings

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

combineStrings

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

The Question

Given a list of strings arr, and a max size n, return a new list where the strings (from left to right) are joined together with a space, so that each new string is less than or equal to the max size.

Examples:

> combineStrings(["a", "b", "c", "d", "e", "f", "g"], 5)
> ["a b c", "d e f", "g"]

> combineStrings(["a", "b", "c", "d", "e", "f", "g"], 12)
> ["a b c d e f", "g"]

> combineStrings(["alpha", "beta", "gamma", "delta", "epsilon"], 20)
> ["alpha beta gamma", "delta epsilon"]

Installing & Running

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