Skip to main content
Back to problems
Leetcode
Easy
Strings
Find Users With Valid E Mails

Filter the user table to return only users whose email addresses match the required school-domain pattern.

Acceptance 50%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

You are given a table of users. Each row contains a user's information, including an email field.

Return the users whose email addresses are considered valid according to the required format:

  • The email must start with a lowercase letter.
  • The remaining characters before @ may contain lowercase letters, digits, underscores, periods, or hyphens.
  • The domain must be exactly leetcode.com.

Only rows matching the rule should be included in the result.

Notes

  • Matching is case-sensitive.
  • The domain must end exactly with leetcode.com and should not contain extra characters before or after it.
  • This is a filtering problem; no transformation of the email string is needed.

Input Format

A table Users with at least these columns:

  • user_id
  • name
  • mail

You should filter rows based on the validity rule for mail.

Output Format

Return the rows of Users that satisfy the valid email rule, preserving the original columns.

Constraints

  • Email addresses are case-sensitive.
  • Valid emails follow the pattern: ^[a-z][a-z0-9._-]*@leetcode\.com$
  • Return all matching rows.
Examples
Sample cases returned by the problem API.

Example 1

Input

Users table
+---------+-------+--------------------------+
| user_id | name  | mail                     |
+---------+-------+--------------------------+
| 1       | Alice | alice@leetcode.com       |
| 2       | Bob   | Bob@leetcode.com         |
| 3       | Carol | carol-123@leetcode.com   |
| 4       | Dave  | dave@leet-code.com       |
+---------+-------+--------------------------+

Output

+---------+-------+--------------------------+
| user_id | name  | mail                     |
+---------+-------+--------------------------+
| 1       | Alice | alice@leetcode.com       |
| 3       | Carol | carol-123@leetcode.com   |
+---------+-------+--------------------------+

Explanation

alice@leetcode.com and carol-123@leetcode.com match the allowed format. Bob@leetcode.com starts with an uppercase letter, and dave@leet-code.com has the wrong domain.

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.