- 
                Notifications
    
You must be signed in to change notification settings  - Fork 266
 
Festival Lineup
        kyra-ptn edited this page Aug 11, 2024 
        ·
        2 revisions
      
    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?
- A: The problem asks to map each artist from a list to their respective set time using dictionaries.
 
 - 
Q: What are the inputs?
- A: Two lists, 
artistsandset_times, both of equal lengthn. 
 - A: Two lists, 
 - 
Q: What are the outputs?
- A: A dictionary where each artist from the 
artistslist is mapped to their corresponding set time from theset_timeslist. 
 - A: A dictionary where each artist from the 
 - 
Q: Can the lists be empty?
- A: Yes, both lists can be empty, resulting in an empty dictionary as output.
 
 - 
Q: Is the order of elements important?
- A: Yes, the order is important as 
artists[i]corresponds toset_times[i]. 
 - A: Yes, the order is important as 
 
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a dictionary by iterating over the lists and mapping each artist to their set time.
1) Initialize an empty dictionary `schedule`.
2) Iterate over the range of the length of the `artists` list.
   - For each index `i`, set `schedule[artists[i]]` to `set_times[i]`.
3) Return the dictionary `schedule`.- Ensure that the lengths of 
artistsandset_timesare equal. - Handle empty lists by returning an empty dictionary.
 
def lineup(artists, set_times):
    schedule = {}
    for i in range(len(artists)):
        schedule[artists[i]] = set_times[i]
    return schedule