Problem Description
Given a table (or DataFrame) of students with columns student_id, name, and age, remove all rows where the value in the name column is missing.
Key Insights
- The problem requires filtering out rows with missing values in the name column.
- You can use built-in filtering methods available in most languages or libraries.
- In Python (with pandas), the dropna method is a simple and efficient way to achieve this.
- In other languages, iterating through the list of records and filtering manually is a common approach.
Space and Time Complexity
Time Complexity: O(n), where n is the number of rows in the DataFrame or list.
Space Complexity: O(n), in the worst case where a new list of filtered elements is created.
Solution
We iterate through the collection of student records and only keep those rows where the name is not missing. In data-centric languages like Python with pandas, built-in functions such as dropna can be used. In other languages, we can iterate through an array or vector of student objects and check if the name field is not null (or the equivalent representation of missing data). The main trick is to correctly identify the missing value (e.g., a null pointer or a 'None' value) and filter accordingly.