Count Alien Pairs from Different Planets
Given N aliens and a list of pairs indicating which aliens live on the same planet, determine the number of ways to pick two aliens such that they belong to different planets.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Late December, 2025
Junior
There are N (1 <= i <= N) aliens living on some number of planets. You are given a list of pairs, where each pair denotes a pair of alien living on the same planet. In how many ways can we pick two aliens such that both these aliens belong to different planets.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.