- 
                Notifications
    You must be signed in to change notification settings 
- Fork 266
All In
        kyra-ptn edited this page Aug 14, 2025 
        ·
        2 revisions
      
    Unit 2 Session 1 (Click for link to problem statements)
- 💡 Difficulty: Easy
- ⏰ Time to complete: 5-10 mins
- 🛠️ Topics: Arrays, Membership Checking
Understand what the interviewer is asking for by using test cases and questions about the problem.
- Established a set (2-3) of test cases to verify their own solution later.
- Established a set (1-2) of edge cases to verify their solution handles complexities.
- Have fully understood the problem and have no clarifying questions.
- Have you verified any Time/Space Constraints for this problem?
- What should be returned if ais empty?- Return Truebecause an empty list is a subset of any list.
 
- Return 
- Can bhave duplicates?- Yes, duplicates in bdo not affect the result.
 
- Yes, duplicates in 
HAPPY CASE
Input: a = [1, 2], b = [1, 2, 3]  
Output: True  
Explanation: Every element in a exists in b.
Input: a = [3, 3], b = [1, 2, 3]  
Output: True  
Explanation: All instances of 3 in a exist in b.
EDGE CASE
Input: a = [], b = [1, 2, 3]  
Output: True  
Explanation: An empty list is trivially a subset.
Input: a = [4], b = [1, 2, 3]  
Output: False  
Explanation: 4 does not exist in b.
Plan the solution with appropriate visualizations and pseudocode.
General Idea:
Check if every element in list a is present in list b.
- Iterate through each element in list a: a) If the element is not inb, return False
- After looping through the full list, return True
- Not considering empty lists or duplicates
Implement the code to solve the algorithm.
def all_in(a, b):
    for elem in a:
        if elem not in b:
            return False
    return True