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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Login Attempts Log Problem
00:00
5 left

Login Attempts Log Problem

EasyPython

Problem

Given a log file of login attempts (each line has status failed/accept, the user who tried to log in and the IP), output the IPs for the user 'hacker' whose attempts have status failed.

Asked in the phone screen stage. Coding problem at the end of the screen.

Input and Output

Implement failed_hacker_ips(log_lines). log_lines is a list of whitespace-separated strings in the format status user ip. Return a list of matching IP strings in their original order. Preserve duplicate IPs. Every input line has exactly three fields and a status of failed or accept.

Constraints

  • 0 <= len(log_lines) <= 10^5
  • Each line contains exactly three whitespace-separated fields: status, user, and IP
  • status is either failed or accept
  • user and IP are non-empty strings
  • Return every matching attempt, including duplicate IPs, in input order

Function Signature

def failed_hacker_ips(log_lines):
Interviewer

Your question is Login Attempts Log Problem. 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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.