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
Even-Length Words & Max Length
00:00
5 left

Even-Length Words & Max Length

EasyPython

Problem

Python: from a sentence, find words with even length and return the maximum length word (if there is a tie, return the one that appeared first)

Asked in the Online assessment stage.

Implement max_even_length_word(sentence). The input is a string, and words are separated by whitespace. Return the original word with the greatest even number of characters, or "" if no word has even length.

Examples

  • "edge node data" returns "edge", because all three words have length 4 and "edge" appears first.
  • "fast CDN delivery" returns "delivery", the longest even-length word.

Constraints

  • sentence contains at most 10,000 characters.
  • Words contain non-whitespace characters.
  • Preserve each selected word exactly as it appears.

Constraints

  • 0 <= len(sentence) <= 10000
  • Words are separated by one or more whitespace characters
  • Return the original spelling and capitalization of the selected word
  • Return an empty string when no word has even length

Function Signature

def max_even_length_word(sentence):
Interviewer

Your question is Even-Length Words & Max Length. 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.