Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Windows or Linux Internals

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

Your question is Windows or Linux Internals. 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

Tell me about a time you had to work with Windows or Linux internals for security.

For the coding portion, analyze process-parent relationships and identify process IDs that participate in a cycle, which can indicate corrupted or tampered process-tree metadata. Implement the function below and return the IDs in ascending order.

Input and Output

events is a list of dictionaries, each containing a unique integer pid and a ppid, which is another process ID or null. Return a list of all process IDs belonging to directed cycles. Parent IDs absent from events represent external roots and cannot form part of a cycle.

Constraints

  • 1 <= len(events) <= 100000
  • Each event contains a unique integer pid
  • pid values are non-negative integers
  • ppid is either null or a non-negative integer
  • A process may reference a parent PID absent from events
  • Return every PID in a cycle, including self-cycles

Function Signature

def find_process_tree_cycles(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output