Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Filter Kubernetes Services by Attributes

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

Your question is Filter Kubernetes Services by Attributes. 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

How would you filter various Kubernetes services based on attributes, status, and dependencies?

Implement the filter using the supplied service metadata. A service matches when its attributes contain every requested key-value pair, its status is allowed, and every transitive dependency exists with status running; dependency cycles invalidate the service.

I/O contract: services maps service names to dictionaries containing attributes, status, and dependencies. Return matching service names in lexicographic order.

Signature: def filter_services(services, required_attributes, allowed_statuses):

Constraints

  • 1 <= number of services <= 10^4
  • Service names are unique strings
  • Each service has attributes, status, and dependencies fields
  • Dependencies contain service names and may form cycles
  • required_attributes contains at most 20 key-value pairs
  • allowed_statuses contains unique strings

Function Signature

def filter_services(services, required_attributes, allowed_statuses):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output