No Handshake
A party has n guests numbered 0 to n - 1. Each entry of handshakes is a pair [a, b]: guests a and b shook hands. The same two guests may shake hands more than once.
Return the guests who shook hands with nobody, in increasing order.
Example 1
n 5
handshakes [[0,1],[3,1]]
returns [2,4]
Guests 0, 1 and 3 each took part in a handshake. Guests 2 and 4 did not.
Example 2
n 3
handshakes []
returns [0,1,2]
Nobody shook hands.
Example 3
n 2
handshakes [[1,0]]
returns []
Both guests shook hands, with each other.
Constraints
1 <= n <= 200 <= len(handshakes) <= 30- a handshake joins two different guests
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Graphs problems
- Who Points at MeBeginner
- Busiest NodeEasy
- Cable GroupsEasy
- Count the LakesEasy
- Everything Needed FirstEasy
- Everything ReachableEasy
- Farthest VillageEasy
- Fewest HopsEasy