LeetCode 2883: Drop Missing Data

Problem Description

Explanation

To solve this problem, we need to iterate through the DataFrame and remove rows where the name column has missing values (e.g., None in Python). We can achieve this by checking each row and only keeping the rows where the name column is not missing.

  • Start by iterating through each row in the DataFrame.
  • Check if the name column in the current row is not missing.
  • If the name column is not missing, add the row to the result DataFrame.
  • Return the resulting DataFrame without the rows containing missing values in the name column.

Time Complexity

The time complexity of this solution is O(n), where n is the number of rows in the DataFrame.

Space Complexity

The space complexity of this solution is O(n) since we need to store the resulting DataFrame.

Solutions

import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<List<Object>> dropMissingData(List<List<Object>> data) {
        List<List<Object>> result = new ArrayList<>();
        
        for (List<Object> row : data) {
            if (row.get(1) != null) {
                result.add(row);
            }
        }
        
        return result;
    }
}

Loading editor...