This is an interview algorithm topic of ThoughtWorks