Interview question in microsoft

Anonymous User
722
Feb 19, 2022
Feb 19, 2022

Can some one help on what approach taken to solve this problem.
It was asked in interview. There is a survelliance camera , which takes the picture of tiger. It is possible that two pictures point to the same tiger. Given N photos and there are M pairs like {1,3}, {3,4} which indicates that 1 and 3 are photo of same tiger, 3 and 4 is photo of same tiger and so on. Find the distinct tiger in forest.

Pair indicates its same photo thats is tiger in phto 1 and photo 3 are same .

Eg:

Assume there are 6 photos N =6
Let M = 3 pairs {{1,2},{3,4},{5,6}}

1->2 is photo of same tiger-> +1
3->4 is photo same of same tiger->+1
5->6 is same ->+ 1

so there are only 3 tigers , the return value should be 3 .

Comments (5)