FastPrepLeft and Right Join Results
Problems/Left and Right Join Results

Left and Right Join Results

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Mastercard phone screen. The report asks for the results of a LEFT JOIN and a RIGHT JOIN, but it leaves out the original tables and the statements. We wrote the simple table layouts, test data with repeated keys, the combined result and the order. Our version is about 72% the same as the reported question.

The tables left_items and right_items each contain uniquely identified rows and a shared join_key.

Return the row-level output of both left_items LEFT JOIN right_items and left_items RIGHT JOIN right_items, using equality on join_key.

Label rows from the first join as LEFT and rows from the second join as RIGHT. Preserve every matching row combination. For an unmatched row, return NULL for every column from the missing side.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

left_items

Rows on the left side of both joins.

ColumnTypeNullableDescription
left_idPKIntegerNo—
join_keyIntegerNo—
left_valueTextNo—

right_items

Rows on the right side of both joins.

ColumnTypeNullableDescription
right_idPKIntegerNo—
join_keyIntegerNo—
right_valueTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
join_typeTextNo—
join_keyIntegerNo—
left_idIntegerYes—
left_valueTextYes—
right_idIntegerYes—
right_valueTextYes—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • left_id is unique in left_items, and right_id is unique in right_items.
  • join_key is non-null; multiple rows may share the same key.
  • Return columns in this order: join_type, join_key, left_id, left_value, right_id, right_value.
  • Sort LEFT rows before RIGHT rows, then by join_key, left_id, and right_id ascending, with a missing ID after non-null IDs.

More Mastercard Phone Screen questions

  • Top Three Accounts by Monthly Transaction AmountPHONE SCREEN · Seen Sep 2026
  • Deduplicate a List While Preserving OrderPHONE SCREEN · Seen Jul 2026
  • Employee With the Highest SalaryPHONE SCREEN · Seen Jul 2026
  • Group Names by DepartmentPHONE SCREEN · Seen Jul 2026
  • Credit and Debit Transaction Counts per UserPHONE SCREEN · Seen Apr 2026
  • Users with Three Transactions in Sixty SecondsPHONE SCREEN · Seen Apr 2026
  • Container With Most WaterPHONE SCREEN · Seen Oct 2025
  • Employees with the Highest and Lowest SalaryPHONE SCREEN · Seen Apr 2025
  • Inactive Customers with Prior ActivityPHONE SCREEN · Seen Nov 2024
  • Merchant Category Transaction SummaryPHONE SCREEN · Seen Nov 2024

Similar questions at other companies

  • Nth Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Email Funnel: Opened Within a Day, Replied Within a WeekSuperhuman · PHONE SCREENSuperhuman interview questions
  • iPhone Model Sales Share by CountryApple · PHONE SCREENApple interview questions
  • In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Top Three Sales per County and YearClickhouse · PHONE SCREEN
  • Block Type with the Most ChildrenNotion · PHONE SCREENNotion interview questions
  • Third-Highest Known SalaryAdobe · PHONE SCREENAdobe interview questions
  • Days Between Each User's Latest Two PostsZip · PHONE SCREENZip interview questions
  • Observed-User Percentage by AppMicrosoft · PHONE SCREENMicrosoft interview questions
  • Nth-Highest Book Sales VolumeAmazon · PHONE SCREEN

Mastercard interview experiences

  • Mastercard Data Science Intern Interviews: 10 Experiences
All Mastercard interview questionsSee Mastercard hiring insights