Skip to content

Bug Report for range-sum-query-immutable #5500

@marskernel

Description

@marskernel

Bug Report for https://neetcode.io/problems/range-sum-query-immutable

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

I think there's a bug with Java. When I run the code I see this error:

Main.java:-4: error: package javafx.util does not exist
import javafx.util.*;
^
1 error

But I don't have any imports in the code. And I don’t think any kind of import is needed for this code.
The problem occurs both on Run and on Submit.

class NumArray {
    int[] prefix;

    public NumArray(int[] nums) {
        this.prefix = new int[nums.length];
        int tot = 0;
        for (int i = 0; i < nums.length; i++) {
            tot += nums[i];
            prefix[i] = tot;
        }
    }
    
    public int sumRange(int left, int right) {
        int preRight = prefix[right];
        int preLeft = left > 0 ? prefix[left - 1] : 0;
        return preRight - preLeft;
    }
}

/**
 * Your NumArray object will be instantiated and called as such:
 * NumArray obj = new NumArray(nums);
 * int param_1 = obj.sumRange(left,right);
 */

AI suggested fix says:

The compilation error was not actually in your logic, but rather an environment issue where the javafx.util.* package was missing from the execution environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions