Added second approach for problem #1