General Motors (GM) interview question

- What was your thought process behind the code?