Skip to main content
Back to problems
Leetcode
Easy
Hash Maps
Strings
Oracle
Delete Duplicate Emails

Remove duplicate email records so that only one row remains for each unique email address.

Acceptance 0%
Problem Statement

Problem

You are given a table of email records. Some email addresses appear in multiple rows. Your task is to remove the duplicate rows so that each email address appears at most once.

When multiple rows share the same email address, keep one row and delete the rest. The exact row to keep is typically the one chosen by the problem's rule (for example, the lowest id or any one row if no tie-break is specified).

Return the cleaned result or the delete action required, depending on the SQL variant of the task.

Goal

Produce a solution that identifies duplicate email values efficiently and removes or filters them correctly.

Input Format

  • A table containing at least an id column and an email column.
  • Multiple rows may share the same email value.

Output Format

  • A result set or SQL operation that leaves only one row per distinct email.
  • Duplicate email rows should be excluded or deleted according to the platform's SQL task format.

Constraints

  • Emails are compared by exact value.
  • Table size may be large enough that a naive row-by-row approach is undesirable.
  • Preserve one representative row for each unique email.
Examples
Sample cases returned by the problem API.

Example 1

Input

id | email
1  | a@b.com
2  | c@d.com
3  | a@b.com

Output

id | email
1  | a@b.com
2  | c@d.com

Explanation

The email a@b.com appears twice, so one of the duplicate rows is removed and only a single row for that email remains.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.