Updated Problem 1. Removed usage of list and second loop.