LeetCode 2884: Modify Columns

Problem Description

Explanation:

To modify the salary column by multiplying each salary by 2, we simply need to iterate through each row of the DataFrame and update the salary value by multiplying it by 2.

  • Time complexity: O(n) where n is the number of rows in the DataFrame.
  • Space complexity: O(1) as we are not using any extra space.

Solutions

public void modifySalary(DataFrame employees) {
    for (int i = 0; i < employees.size(); i++) {
        int currentSalary = employees.get(i, "salary");
        employees.set(i, "salary", currentSalary * 2);
    }
}

Loading editor...