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
Solve Two Sum and Longest Substring
00:00
5 left

Solve Two Sum and Longest Substring

EasyPython

Problem

A Samsung Exynos mobile diagnostics utility receives numeric event data and a compact identifier string. Implement one function that performs two independent analyses: find the indices of two array values that sum to a target, and compute the length of the longest substring containing no repeated characters.

Formal Specification

Implement solve_mobile_arrays(nums, target, s).

  1. For the integer array nums, return the indices of the two distinct elements whose values sum to target. Return the indices in ascending order. Each valid input contains exactly one pair.
  2. For the string s, return the length of its longest substring with all unique characters.
  3. Return a dictionary with keys two_sum and longest_substring, where two_sum maps to the index pair and longest_substring maps to the integer length.

Characters are compared exactly as supplied, including case and whitespace.

Constraints

  • 2 <= len(nums) <= 10^5
  • 0 <= len(s) <= 10^5
  • -10^9 <= nums[i], target <= 10^9
  • nums contains exactly one valid two-sum pair
  • s may contain any standard Unicode characters

Function Signature

def solve_mobile_arrays(nums, target, s):
Interviewer

Your question is Solve Two Sum and Longest Substring. 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.