Skip to content

179 - Contains Duplicate - typescript #182

Open
@jsartisan

Description

@jsartisan

index.ts

export function hasDuplicate(numbers: number[]): boolean {
  const uniqueNumbers: Set<number> = new Set();

  for (const num of numbers) {
    if (uniqueNumbers.has(num)) {
      return true; // Duplicate found
    }

    uniqueNumbers.add(num);
  }

  return false; // No duplicates found
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions