Unit 2 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Q: What is the problem asking for?
Q: What are the inputs?
venue1_schedule
and venue2_schedule
, each mapping artists to their set times.Q: What are the outputs?
Q: What constitutes a conflict?
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Compare the set times of artists in both venue schedules and collect the ones that match.
1) Initialize an empty dictionary `conflicts`.
2) Iterate over each artist and their set time in `venue1_schedule`.
- Check if the artist is also in `venue2_schedule` and if their set time matches the set time in `venue1_schedule`.
- If both conditions are met, add the artist and their set time to the `conflicts` dictionary.
3) Return the `conflicts` dictionary.
⚠️ Common Mistakes
def identify_conflicts(venue1_schedule, venue2_schedule):
conflicts = {}
for artist, time in venue1_schedule.items():
if artist in venue2_schedule and venue2_schedule[artist] == time:
conflicts[artist] = time
return conflicts