Bird
Raised Fist0

Given the following memoization cache state for Two City Scheduling at i=3, a_count=1 with memo[(3,1)] = 250, what could be the original costs input for the first 4 people?

hard🔄 Reverse Engineer Q9 of Q15
Greedy Algorithms - Two City Scheduling
Given the following memoization cache state for Two City Scheduling at i=3, a_count=1 with memo[(3,1)] = 250, what could be the original costs input for the first 4 people?
A[[20,10],[200,30],[50,400],[20,30]]
B[[10,20],[30,200],[400,50],[30,20]]
C[[10,20],[200,30],[50,400],[20,30]]
D[[10,20],[30,200],[50,400],[30,20]]
Step-by-Step Solution
Solution:
  1. Step 1: Understand memo meaning

    memo[(3,1)] = 250 means minimum cost after assigning first 3 people with 1 assigned to city A.
  2. Step 2: Match costs to memo state

    [[10,20],[200,30],[50,400],[20,30]] matches cost pattern where assigning second person to city B (200,30) and third to city B (50,400) leads to total 250 at this state.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Only [[10,20],[200,30],[50,400],[20,30]] matches memo cost and assignment counts [OK]
Quick Trick: Match memo state with partial assignments and costs [OK]
Common Mistakes:
MISTAKES
  • Ignoring assignment counts in memo
  • Confusing cost order
  • Assuming memo stores total cost for all people
Trap Explanation:
PITFALL
  • Candidates often fail to reason backward from memo to input costs.
Interviewer Note:
CONTEXT
  • Tests deep understanding of DP memoization states
Master "Two City Scheduling" in Greedy Algorithms

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Greedy Algorithms Quizzes