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

Courses Shared by Every Student Pair

Indeed logoIndeed● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Indeed phone screen. The task is to list every pair of students and the courses they share. Our version is about 95% the same as the report, and keeps all three original datasets and pairs with no shared courses. The original output may be in any order. We chose sorted rows of different lengths, exact text IDs, how duplicates and empty results work, and the limits. The report names Indeed SDET, and Karat as the provider.

Each row of enrollments is [studentID,courseName]. For every pair of different students, return the courses they both take. Include pairs that share no course.

For this exercise, assume only student IDs that appear in the input are included, duplicate enrollments have no effect, and IDs and course names are compared as complete case-sensitive strings. Different leading-zero ID spellings are distinct identifiers.

For this exercise, assume each unordered pair is returned once as [firstID,secondID,course1,...]. Put the two IDs in ASCII lexicographic order, sort the distinct common courses in that order, and sort result rows by their two IDs. A pair without a common course has exactly two fields.

For this exercise, assume empty input or one represented student returns an empty array.

Function

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

Examples

Example 1

enrollments = [["58","Linear Algebra"],["94","Art History"],["94","Operating Systems"],["17","Software Design"],["58","Mechanics"],["58","Economics"],["17","Linear Algebra"],["17","Political Science"],["94","Economics"],["25","Economics"],["58","Software Design"]]return = [["17","25"],["17","58","Linear Algebra","Software Design"],["17","94"],["25","58","Economics"],["25","94","Economics"],["58","94","Economics"]]

Students 17 and 58 share Linear Algebra and Software Design. Every student pair appears, including the two pairs without a shared course.

Example 2

enrollments = [["0","Advanced Mechanics"],["0","Art History"],["1","Course 1"],["1","Course 2"],["2","Computer Architecture"],["3","Course 1"],["3","Course 2"],["4","Algorithms"]]return = [["0","1"],["0","2"],["0","3"],["0","4"],["1","2"],["1","3","Course 1","Course 2"],["1","4"],["2","3"],["2","4"],["3","4"]]

Students 1 and 3 share Course 1 and Course 2; the other nine student pairs have no common course.

Constraints

  • For this exercise, assume 0 <= enrollments.length <= 120 and at most 20 distinct students.
  • For this exercise, assume at most 10 distinct courses per student.
  • Each row has exactly two strings. For this exercise, assume IDs have 1 through 10 decimal digits, and course names have 1 through 30 ASCII letters, digits or spaces.

More Indeed Phone Screen questions

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
  • Rotting Orange PropagationPHONE SCREEN · Seen May 2025
  • First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
  • Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
  • Resource Transition GraphPHONE SCREEN · Seen Jul 2022
  • Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022
  • Word Path Moving Only Right or DownPHONE SCREEN · Seen Jul 2022

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Bank Account Balances (Part 2): Monthly ReconciliationStripe · PHONE SCREENStripe interview questions
  • Time-Aware Search AutocompleteRoblox · PHONE SCREENRoblox interview questions
  • Top Ten Most Frequent Words in a BookRobinhood · PHONE SCREENRobinhood interview questions
  • Group AnagramsEPAM · PHONE SCREENEPAM interview questions
  • Aggregate Matching IPv4 Addresses Across ResponsesPinterest · PHONE SCREENPinterest interview questions
  • Diff Two Filesystem Hash TreesCursor · PHONE SCREENCursor interview questions
  • Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
  • Group AnagramsJFrog · PHONE SCREEN

Interview reports that mention this question

  • Indeed Experienced SWE Karat Screens and OAs: 6 Experiences

Indeed interview experiences

  • Indeed SWE Intern Karat Screens and OA: 3 Experiences
  • Indeed New Grad SWE Online Assessments: 3 Experiences
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public String[][] sharedCourses(String[][] enrollments) {
        // Write your code here.
        return new String[0][0];
    }
}
Checking account…