Added solution to q5 - does not cover edge cases