Motive interview question

Lc chanllenges with different solutions. CS basics.