Filter the user table to return only users whose email addresses match the required school-domain pattern.
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:
@ may contain lowercase letters, digits, underscores, periods, or hyphens.leetcode.com.Only rows matching the rule should be included in the result.
leetcode.com and should not contain extra characters before or after it.A table Users with at least these columns:
user_idnamemailYou should filter rows based on the validity rule for mail.
Return the rows of Users that satisfy the valid email rule, preserving the original columns.
^[a-z][a-z0-9._-]*@leetcode\.com$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
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.