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-duplicates-from-sorted-array #4879

Open
@Anfebule

Description

@Anfebule

Bug Report forhttps://neetcode.io/problems/remove-duplicates-from-sorted-array

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

This is my simplest proposed solution in Java for this problem:

class Solution {    public int removeDuplicates(int[] nums) {        Set<Integer> arraySet = new HashSet();        for (int num: nums){            arraySet.add(num);        }        return arraySet.size();    }}

The platform returns the solution is incorrect as follows:
Input:
nums=[1,1,2,3,4]

Your Output:
[1,1,2,3]

Expected output:
[1,2,3,4]

Tested it out in an IDE, the result is according to the expected output, as by definition a Set doesn't allow duplicated values.

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