Here is my solution for bloomberg interview question found in careercup