Check Consistency of Same-Person and Different-Person Account Assertions

Last updated: November 29, 2026

Quick Overview

Signals from different anti-fraud rules assert that two account IDs are the same person or are different people; return True if all assertions can hold at once.

ByteDance
Coding & Algorithms
Software Engineer
ByteDance
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Signals from different anti-fraud rules assert that two account IDs are the same person or are different people; return True if all assertions can hold at once.

ByteDance's risk control teams merge identity signals from devices, payments and logins, and contradictory rules have to be caught before accounts are banned together. This union-find question in their screening style checks that you process equalities before inequalities and use path compression.

What the Interviewer Expects
  • Realize equality is transitive, so components matter
  • Union all == assertions first, then check every !=
  • Implement find with path compression
  • Handle an account asserted different from itself
  • State near-linear time
Key Topics to Cover
union find
path compression
equivalence relations
graph components
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Assertions arrive one at a time: report the first one that causes a contradiction.
  • Each assertion has a confidence score: drop the fewest low-confidence ones to restore consistency.
  • How would you shard this across machines for billions of accounts?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: a list of (a, op, b) where op is "==" or "!=" and a, b are account ID strings. Output: True if there is an assignment of people to accounts satisfying every assertion. IDs not seen before are t...

High-Level Design

Same-person is an equivalence relation, so the == assertions partition accounts into components. A != assertion is violated exactly when both sides land in the same component. Doing all unions first a...


Submit Your Answer
Markdown supported