FastPrepCheck Inequality Constraint Consistency
Problems/Check Inequality Constraint Consistency

Check Inequality Constraint Consistency

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives strict comparisons, a contradictory cycle, and a follow-up that adds non-strict comparisons. We fixed the values to be real numbers and set the input grammar. Our version is about 94% the same as the reported question.

You are given comparisons between named variables. Each string has the form left<right, left<=right, left>right, or left>=right. Variable names contain lowercase English letters.

Decide whether real values can be assigned to all variables so that every comparison is true.

Whitespace does not occur. Repeated comparisons are allowed.

Function

areInequalitiesConsistent(relations: String[]) → boolean

Examples

Example 1

relations = ["a>b","b>c","d<e"]return = true

For example, choose a=2,b=1,c=0,d=0,e=1.

Example 2

relations = ["a>b","b>c","c>a"]return = false

The strict cycle would require a>b>c>a.

Example 3

relations = ["a<=b","b<=a"]return = true

Both relations hold when a=b.

Constraints

  • 0 <= relations.length <= 200000.
  • Each variable name has length in [1,20] and contains only lowercase English letters.
  • Every relation uses exactly one of <, <=, >, or >=.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Merge Event PreferencesAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Topological OrderingApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend Referral RecommendationsFireworks AI · PHONE SCREEN · ONSITE INTERVIEW
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Network Layer Execution OrderNVIDIA · PHONE SCREENNVIDIA interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Shortest Pin Path Through TopicsPinterest · PHONE SCREENPinterest interview questions
  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN

Interview reports that mention this question

  • Google New Grad SWE Interview Questions Guide (Part 1 of 2)
  • Google L4 PhD New Grad Timeline: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean areInequalitiesConsistent(String[] relations) {
        // Write your code here.
    }
}
Checking account…