Java Interview Question: Remove Inactive Users Efficiently
Efficient User Cleanup in Large Datasets
Problem Description
Imagine you’re working on a user access control system for an application, and you need to clean up a list of users who have been marked as inactive. Your goal is to remove all inactive users (status = INACTIVE) from the list while keeping the operation efficient and minimizing memory usage.
The current solution creates a new list to store active users, which is memory inefficient for large lists.
How would you modify the solution to improve memory usage by operating in place?
What is the time complexity of your proposed solution, and how does it compare to the existing approach?
Keep reading with a 7-day free trial
Subscribe to Java Newsletter to keep reading this post and get 7 days of free access to the full post archives.