Apple iOS Software Engineer

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-05-30Added By Anonymous
Source: Link

Overview

A destination city is in need of supplies which can be supplied only from supplier cities which may or may not be accessible to the destination city through connections to intermediate cities.


Create a construct with functions taking a destination city that compute the following:

•Determine how many supplier cities are connected (either directly or indirectly) to the destination city
•Find the time from the nearest (by time) supplier city to the destination city.


Rules

•Each city is specified by a unique integer identifier.
•Direct connections may be traversed in either direction
•It costs one unit of time to pass through a direct connection between two cities


Construct Given

•Array of connections as tuple pairs
•Set of supplier cities.


Functions Given

•Destination city
Comments