Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find the Added Element

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Find the Added Element. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Tinder Discovery compares candidate profile identifiers from two processing stages. Given two integer lists that contain exactly the same elements with the same multiplicities, except that one list contains one additional element, return the value of that extra element.

The lists may be in different orders, and values may be repeated. Do not modify either input list.

Formal Specification

Implement find_extra_element(shorter, longer), where shorter and longer are lists of integers and len(longer) == len(shorter) + 1. Return the integer whose occurrence count in longer is one greater than its count in shorter.

Constraints

  • 0 <= len(shorter) <= 100,000
  • len(longer) == len(shorter) + 1
  • -10^9 <= value <= 10^9
  • The lists contain the same multiset except for one extra occurrence in longer

Function Signature

def find_extra_element(shorter, longer):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output