- 
                Notifications
    
You must be signed in to change notification settings  - Fork 266
 
VIP Passes and Guests
        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 return the number of guests who have VIP passes by comparing two strings.
 
 - 
Q: What are the inputs?
- A: Two strings 
vip_passesandguests, wherevip_passesrepresents the types of guests with VIP passes andguestsrepresents the types of guests at the festival. 
 - A: Two strings 
 - 
Q: What are the outputs?
- A: An integer representing the number of guests who have VIP passes.
 
 - 
Q: Are the characters case-sensitive?
- A: Yes, characters are case-sensitive.
 
 
Plan the solution with appropriate visualizations and pseudocode.
For this problem, the Plan step was provided to you.
1. Create an empty set called vip_set.
2. For each character in vip_passes, add it to vip_set.
3. Initialize a counter variable to 0.
4. For each character in guests:
   - If the character is in vip_set, increment the count by 1.
5. Return the count.
def num_VIP_guests(vip_passes, guests):
    # Step 1: Create an empty set called vip_set
    vip_set = set()
    
    # Step 2: For each character in vip_passes, add it to vip_set
    for vip in vip_passes:
        vip_set.add(vip)
    
    # Step 3: Initialize a counter variable to 0
    count = 0
    
    # Step 4: For each character in guests, if it is in vip_set, increment the count
    for guest in guests:
        if guest in vip_set:
            count += 1
    
    # Step 5: Return the count
    return count