Implemented given test case
Implemented solution
Refactored for mild performance improvement
Merge branch 'problem5'