ThoughtWorks Coding problem