FastPrepPossible Bipartition
Problems/Possible Bipartition

Possible Bipartition

Maven Clinic logoMaven Clinic● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Maven Clinic phone screen report names a well-known problem and BFS as the interview problem. Our version uses the usual Possible Bipartition yes or no question. It is about 99% the same as the reported question.

There are n people labeled from 1 to n. Each pair [a, b] in dislikes means that a and b must be placed in different groups.

Return true if all people can be split into two groups satisfying every pair, otherwise return false.

Function

possibleBipartition(n: int, dislikes: int[][]) → boolean

Examples

Example 1

n = 4dislikes = [[1,2],[1,3],[2,4]]return = true

One valid split is {1,4} and {2,3}.

Example 2

n = 3dislikes = [[1,2],[1,3],[2,3]]return = false

The three people form an odd cycle, so two groups are impossible.

Constraints

  • 1 <= n <= 2000.
  • 0 <= dislikes.length <= 10000.
  • 1 <= a, b <= n and a != b.
  • No dislike pair is duplicated.

More Maven Clinic interview questions

  • Minimum Appointment Cancellations with a Required BreakPHONE SCREEN · Seen Jun 2026
  • Shortest Currency Conversion with Three-Decimal RatePHONE SCREEN · Seen Mar 2026
  • Configurable Valid BracketsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2025
  • Meeting Rooms IIPHONE SCREEN · Seen Aug 2025
  • Paginate Provider Listings with Per-Page DiversityONSITE INTERVIEW · Seen Apr 2026
  • Longest Valid ParenthesesONSITE INTERVIEW · Seen Aug 2025

Similar questions at other companies

  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Evaluate DivisionApple · PHONE SCREENApple interview questions
  • Possible BipartitionByteDance · PHONE SCREENByteDance interview questions
  • Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
  • Count Friend CirclesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Number of IslandsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Count Connected IslandsUber · PHONE SCREENUber interview questions
  • Course ScheduleNykaa · PHONE SCREENNykaa interview questions
  • Number of IslandsSpaceX · PHONE SCREENSpaceX interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
All Maven Clinic interview questionsSee Maven Clinic hiring insights
Saved
class Solution {
    public boolean possibleBipartition(int n, int[][] dislikes) {
        // Write your code here.
    }
}
Checking account…