Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Subset Check for Integers

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

Your question is Subset Check for Integers. 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

Sumitomo Mitsui Banking Corporation may receive integer collections representing permitted and requested transaction classifications. Given two integer lists, determine whether the first list represents a subset of the second list.

Treat each list as a mathematical set, so duplicate values do not affect the result. Return True if every distinct value in candidate occurs in reference; otherwise, return False. The input lists may be unsorted, and the function must not modify either list.

Formal Specification

Implement is_subset(candidate, reference).

  • Input: Two lists of integers, candidate and reference.
  • Output: A Boolean. Return True when set(candidate) is contained in set(reference), and False otherwise.

Constraints

  • 0 <= len(candidate), len(reference) <= 100,000
  • -10^9 <= candidate[i], reference[i] <= 10^9
  • Input lists may contain duplicates
  • Input lists may be unsorted
  • Neither input list may be modified

Function Signature

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