GTS interview question

Single coding question with 4 hours to complete