FastPrepCourses Shared by Every Student Pair
Problems/Courses Shared by Every Student Pair

Courses Shared by Every Student Pair

Robinhood logoRobinhood● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported every-student-pair shared-course capability matches at about 90%; finite String[][] representation, sorting, duplicate/empty behavior, empty-overlap pairs and bounds are explicit practice assumptions. Robinhood is the hiring client and Karat the outsourced provider.

Each row of enrollments is [studentName,courseName]. For every pair of distinct students, return the courses they both take.

For this exercise, assume duplicate enrollments have no effect, and only students appearing in the input are represented. Compare names and courses as complete case-sensitive strings.

For this exercise, return every unordered pair once, including pairs with no shared course. Each result row is [firstStudent,secondStudent,course1,...], with its two names in lexicographic order followed by sorted unique common courses. A pair without a common course has exactly two fields.

For this exercise, assume result rows are ordered lexicographically by their student-name pair. Empty input or one represented student returns an empty array.

Function

sharedCoursePairs(enrollments: String[][]) → String[][]

Examples

Example 1

enrollments = [["A","Math"],["A","Art"],["B","Math"],["C","Art"]]return = [["A","B","Math"],["A","C","Art"],["B","C"]]

These rows include every pair; B/C has no shared course and returns only its two names.

Example 2

enrollments = [["Alice","Math"],["Alice","Math"],["Bob","Math"],["Bob","Art"]]return = [["Alice","Bob","Math"]]

This repeated enrollment contributes one shared Math entry.

Constraints

  • For this exercise, assume 0 <= enrollments.length <= 120, with exactly two strings per row and at most 20 distinct students.
  • For this exercise, assume all names are nonempty case-sensitive printable ASCII strings of length 1 through 10.
  • Repeated enrollment rows may appear and have no additional effect.

More Robinhood interview questions

  • Top Ten Most Frequent Words in a BookPHONE SCREEN · Seen Oct 2026
  • Fractional Share Inventory FlatteningPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Unique Transitive Dependent CountsPHONE SCREEN · Seen Sep 2026
  • Service Dependency Load FactorsPHONE SCREEN · Seen Sep 2026
  • Word Frequency in a Large TextPHONE SCREEN · Seen Jul 2026
  • Earliest One-Hour Badge Alert TimesPHONE SCREEN · Seen Sep 2021
  • Middle Course in One Prerequisite ChainPHONE SCREEN · Seen Sep 2019
  • Friendship and Balance TrackerONSITE INTERVIEW · Seen Sep 2026
  • Transitive Employee Referral CountsONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Recipe Rating ServiceNubank · PHONE SCREEN
  • Merge Accounts by Shared AttributeAmazon · PHONE SCREEN
  • Warehouse Order PrioritizationDoorDash · PHONE SCREENDoorDash interview questions
  • Mutual-Friend Referral RecommendationsFireworks AI · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Log Analyzer: Busiest Service in a Rolling WindowByteDance · PHONE SCREENByteDance interview questions
  • User Journey PathsWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesStripe · PHONE SCREENStripe interview questions
All Robinhood interview questionsSee Robinhood hiring insights
Saved
class Solution {
    public String[][] sharedCoursePairs(String[][] enrollments) {
        // Write your code here.
        return new String[0][0];
    }
}
Checking account…