Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug Report for remove-element #4880

Open
@Anfebule

Description

@Anfebule

Bug Report forhttps://neetcode.io/problems/remove-element

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

Here again, my simplest solution in Java for this problem is as follows:

class Solution {    public int removeElement(int[] nums, int val) {        List<Integer> newNums = new ArrayList<>();        for(int num: nums){            if(num != val){                newNums.add(num);            }        }        return newNums.size();    }}

The response on the platform is:

Input:
nums=[1,1,2,3,4]
val=1

Your Output:
[1,1,2]

Expected output:
[2,3,4]

My output is not correct according to the platform; I tested it out in an IDE, and the content of my variable (newNums) at the end is [2,3,4].

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp