Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Algorithmic List and Dict Problem
00:00
5 left

Algorithmic List and Dict Problem

MediumPython

Problem

Solve an algorithmic problem involving list manipulation or dictionary lookups. Implement order_items(items, priority), returning a new list sorted by each item's integer priority. Items missing from priority must appear after prioritized items, and relative order must remain stable for equal or missing priorities.

Input/output contract: items is a list of strings and priority is a dictionary mapping strings to integers. Return a list of strings.

Constraints

  • 0 <= len(items) <= 1000
  • Each item is a string
  • priority maps strings to integer priorities
  • An item may be absent from priority
  • Return a new list and do not modify items

Function Signature

def order_items(items, priority):
Interviewer

Your question is Algorithmic List and Dict 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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.