Skip to content

Bug Report for can-place-flowers #5531

@benmak11

Description

@benmak11

Bug Report for https://neetcode.io/problems/can-place-flowers

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

I cannot run any solution that I type into the IDE. The error that keeps on coming back is:

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

I don't even import that package from the source code below:

class Solution {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        if (n == 0) return true;
        
        for (int i = 0; i < flowerbed.length; i++) {
            if (flowerbed[i] == 0) {
                boolean prevEmpty = (i == 0) || (flowerbed[i - 1] == 0);
                boolean nextEmpty = (i == flowerbed.length - 1) || (flowerbed[i + 1] == 0);
                
                if (prevEmpty && nextEmpty) {
                    flowerbed[i] = 1;
                    n--;
                }
            }
            if (n <= 0) return true;
        }

        return n <= 0;
    }
}

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