Python Interview Prep/The Salary Gap
LinkedIn logo

The Salary Gap

LinkedIn·easy·pandas·About 10 min in the room

employees holds each person's salary and their department_id; departments maps each id to a department name. Find the absolute difference between the highest salary in Marketing and the highest salary in Engineering, and store that number in result.

The data

employees10 rows
idint64first_nameobjectsalaryfloat64department_idint64
1Priya980002
2Tom1215001
3Ines870002
4Kofi1340001
5MeiNaN2
6Raj760003
and 4 more rows
departments3 rows
idint64nameobject
1Engineering
2Marketing
3Sales

Target output

np.float64(5000.0)

What this question tests

Tests a merge on keys with different names and a group maximum, with two small traps: a missing salary, and the word "absolute". It is a common first question because it is short enough to finish and still separates people who check their join from people who hope.

More Python interview questions

  • Weeks at Number One · Spotify · easy
  • Month-over-Month Revenue · Amazon · medium
  • Back Within a Week · Amazon · medium
  • Average Session Length · Meta · medium
Python
Shift+EnterPython is starting in your browser...
Output

Starting Python...