medium
Optimize Python Loop
Refactor a nested loop in Python to improve performance and readability.
📝 Treść promptu
Review the following Python code snippet which contains a nested loop used to filter a list of user dictionaries. Refactor the code to use a list comprehension or a more efficient data structure (like a dictionary or set) to reduce time complexity from O(n^2) to O(n). Explain the changes made and why they are more efficient. Code: users = [...] # list of dicts, filter criteria.