General Motors (GM) interview question

Basic leetcode questions, one was easy and one was difficult