CityGrid Media Interview Question

Converting a recursive function to non-recursive version.