Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Login Attempts Log Problem

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

Your question is Login Attempts Log Problem. 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

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):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output