Question bank › Union Find
Dsa Union Find Medium

Feedback Grouping

In a feedback system, users can give feedback about other users. Each feedback can either be positive or negative. Your task is to group users based on their feedback relationships. If one user gives positive feedback about another, they belong to the same group. If negative feedback is given, they are in different groups. Input Format: - The first line contains an integer F, the number of feedback entries (1 <= F <= 10000). - The next F lines contain three elements: - Feedback_type (either 'P' for positive or 'N' for negative) - User_A (1 <= User_A <= 1000) - User_B (1 <= User_B <= 1000) Output Format: - Print the number of distinct groups at the end of processing all feedback entries. Example: Input: 5 P 1 2 P 2 3 N 1 4 P 4 5 N 5 3 Output: 3 Note: - Positive feedback leads to union, negative feedback to separation.

Key concepts

union_findgroupingsocial_network

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.