Python data engineering interview problem. Difficulty: beginner. Pattern: Sorting. About 10 minutes. Part of the Pro drill bank.
Finance dumps daily order totals into a list. Reporting wants the second-highest distinct amount so they can compare the runner-up basket to the winner, even when many orders share the top value.
Return the second-largest distinct number from a list of order totals.
Input: second_largest([1, 5, 5, 3]) Output: 3 This input follows the stated rules and produces this output.
Topics: lakebench, python, lists.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Given a list of order totals, return the second-largest distinct value.
Return the second-largest distinct number from a list of order totals.