people residents numbered from 0 to people - 1. Each pair [a, b] in friendships means a and b know each other (both ways).
A *group* is a set of residents linked by chains of acquaintances that nobody outside can join: no one inside knows anyone outside. A loner with no acquaintances is a group too.
Return the number of groups in which **every** member directly knows **every** other member.people=5, friendships=[[0, 1], [1, 2], [2, 0], [3, 4]] → 2
Groups {0, 1, 2} and {3, 4}: in each, everyone knows everyone.
people=4, friendships=[[0, 1], [1, 2], [3, 0]] → 0
All four are in one group, but 0 and 2, for example, are strangers, so the answer is 0.
people=3, friendships=[] → 3
people=5, friendships=[[0, 1], [1, 2], [2, 0], [3, 4]]
2
Run checks the first 3 tests in your browser. Submit checks all 60 tests on the server, hidden ones included.