← Back to experiences
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/experiences/…$
Microsoft On-site Coding Round**
Interview Experience:
Given n cities numbered from 0 to n-1 connected in a doubly linked manner, and m amenities (numbered 0 to m-1) for each city. A matrix amenities of size n x m is provided, where amenities[i][j] = 1 indicates the presence of amenity j in city i, and 0 indicates its absence. The distance between any two adjacent cities is 1.
Find the city with the smallest distance to access all amenities.
Example:
`cpp int n = 5, m = 3; vector<vector<int>> inp = { {1, 0, 0}, {0, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1} };
// ans = 3 (city 3 has a distance of 2 to access all amenities) `