Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Efficient Protein Motif Detection
00:00
5 left

Efficient Protein Motif Detection

HardPython

Problem

Genentech's protein analysis pipelines need to identify short sequence motifs shared across multiple candidate proteins. Given a collection of protein sequences, find every contiguous motif of length k that occurs in at least min_sequences distinct sequences.

Count each motif at most once per sequence, even if it appears multiple times within that sequence. Return the motifs in lexicographic order.

Formal Specification

Implement find_common_motifs(sequences, k, min_sequences), where sequences is a list of uppercase protein sequences, k is the motif length, and min_sequences is the minimum number of distinct input sequences that must contain a motif. Return a list of strings.

Example 1: sequences = ["MOTIF", "AMOTIF", "XXMOTIF"], k = 3, min_sequences = 2 returns ["MOT", "OTI", "TIF"], because each motif appears in at least two sequences.

Example 2: sequences = ["AAAA", "AAAT", "AAGA"], k = 2, min_sequences = 2 returns ["AA"]. Repeated occurrences of AA within AAAA count only once for that sequence.

Constraints

  • 1 <= len(sequences) <= 10^4
  • 1 <= k <= 100
  • k <= len(sequence) <= 10^5
  • The total number of input characters is at most 10^6
  • 1 <= min_sequences <= len(sequences)
  • Sequences contain uppercase alphabetic characters only

Function Signature

def find_common_motifs(sequences, k, min_sequences):
Interviewer

Your question is Efficient Protein Motif Detection. Start with the requirements in the Question tab.

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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.