Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Queueing Shipping Types

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

Your question is Queueing Shipping Types. 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

Fashion Nova needs to arrange fulfillment orders in shipping priority order. Given an arrival list and an explicit priority ranking, return a new queue with higher-priority shipping types first while preserving the original arrival order among orders with the same type.

Do not modify the input list. You may assume every order uses a shipping type present in priority.

Formal Specification

Implement queue_shipping_orders(orders, priority).

  • orders is a list of dictionaries. Each dictionary contains a string key shipping_type and may contain other fields such as order_id.
  • priority is a list of distinct shipping type strings, ordered from highest priority to lowest priority.
  • Return a list of the same order dictionaries, arranged according to priority.
  • The result must be stable: orders sharing a shipping type remain in their original relative order.

Constraints

  • 1 <= len(orders) <= 10^5
  • 1 <= len(priority) <= 10^3
  • Every order shipping type appears in priority
  • Shipping types in priority are distinct
  • The input list must not be modified

Function Signature

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