General Motors (GM) interview question

Sifting through given arrays and strings