FastPrepValidate and Complete Racer Precedence
Problems/Validate and Complete Racer Precedence

Validate and Complete Racer Precedence

Microsoft logoMicrosoft● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft intern onsite interview. The report gives the main task and the interview setting. We rebuilt the function signature, the output order, the examples and the limits to stay close to it. Our version is about 90% the same as the reported question.

Each pair [before,after] states that racer before finished ahead of racer after. Racer names are the names appearing in at least one pair.

Return four strings: whether the data is acyclic, whether it determines one complete total order, the first racer, and the last racer. Boolean fields are "true" or "false". If the data is cyclic or does not determine a unique total order, return empty strings for first and last. Duplicate relations do not change the result.

Function

analyzeRaceOrder(relations: String[][]) → String[]

Examples

Example 1

relations = [["A","B"],["B","C"],["C","D"]]return = ["true","true","A","D"]

The DAG has one topological order from A to D.

Example 2

relations = [["A","C"],["B","C"]]return = ["true","false","",""]

The data is valid but A and B are incomparable.

Example 3

relations = [["A","B"],["B","A"]]return = ["false","false","",""]

The cycle makes the data invalid.

Constraints

  • 0 <= relations.length <= 100000.
  • Names are nonempty.

More Microsoft Onsite Interview questions

  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026
  • Totals from a Tiered Rate TableONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Can Subsequences Share One Master Sequence?Google · ONSITE INTERVIEWGoogle interview questions
  • Password From Ordering HintsRogo · ONSITE INTERVIEW
  • Alien DictionaryByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Alien DictionaryBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Alien DictionaryAmazon · ONSITE INTERVIEW
  • Letter Order from a Sorted Word ListRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Validate CSV References and Field DependenciesStripe · PHONE SCREENStripe interview questions
  • Alien DictionaryIntuit · OAIntuit interview questions
  • Recover an Alien Alphabet from Sorted WordsOpenAI · PHONE SCREENOpenAI interview questions

Interview reports that mention this question

  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] analyzeRaceOrder(String[][] relations) {
        // write your code here
    }
}
Checking account…