Count Delivery Addresses after Local-Name Dot and Plus Rules
Company: Microsoft
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
For this task's email-address rules, split each string at its single `@`. In the local part only, discard every dot and ignore the first plus sign and everything following it. Leave the domain unchanged. Return the number of distinct resulting delivery addresses. These rules describe the supplied problem model, not a claim about all email providers.
```cpp
class Solution {
public:
int numUniqueEmails(vector<string>& emails);
};
```
### Examples
**Example 1:**
```text
Input: emails = ["a.b+tag@sample.com","ab@sample.com","ab@sa.mple.com"]
Output: 2
Explanation: The first two normalize to ab@sample.com. The domain dot in sa.mple.com remains significant.
```
**Example 2:**
```text
Input: emails = ["x+u@a.com","x+v@a.com","x@b.com"]
Output: 2
Explanation: Both a.com addresses deliver to x@a.com; x@b.com remains separate.
```
### Constraints
- `1 <= emails.length <= 100`.
- `1 <= emails[i].length <= 100`.
- Characters are lowercase English letters, `+`, `.`, and `@`.
- Each address has exactly one `@`; local and domain names are nonempty.
- Local names do not start with `+`.
- Domains end with `.com` and contain at least one character before that suffix.
### Contract considerations
Only lowercase letters, plus,dot and @ occur. Domain names end in .com and have at least one character before that suffix.
```hint Read the boundary condition
The at-sign separates two regions with different transformation rules.
```
### Boundary reminders
Only lowercase letters, plus,dot and @ occur. Domain names end in .com and have at least one character before that suffix.
Overview: Count Delivery Addresses after Local-Name Dot and Plus Rules. For this task's email-address rules, split each string at its single @.
Count Delivery Addresses after Local-Name Dot and Plus Rules
Microsoft
Jun 24, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0
Problem
For this task's email-address rules, split each string at its single @. In the local part only, discard every dot and ignore the first plus sign and everything following it. Leave the domain unchanged. Return the number of distinct resulting delivery addresses. These rules describe the supplied problem model, not a claim about all email providers.
class Solution {
public:
int numUniqueEmails(vector<string>& emails);
};
Examples
Example 1:
Input: emails = ["a.b+tag@sample.com","ab@sample.com","ab@sa.mple.com"]
Output: 2
Explanation: The first two normalize to ab@sample.com. The domain dot in sa.mple.com remains significant.
Example 2:
Input: emails = ["x+u@a.com","x+v@a.com","x@b.com"]
Output: 2
Explanation: Both a.com addresses deliver to x@a.com; x@b.com remains separate.
Constraints
1 <= emails.length <= 100
.
1 <= emails[i].length <= 100
.
Characters are lowercase English letters,
+
,
.
, and
@
.
Each address has exactly one
@
; local and domain names are nonempty.
Local names do not start with
+
.
Domains end with
.com
and contain at least one character before that suffix.
Contract considerations
Only lowercase letters, plus,dot and @ occur. Domain names end in .com and have at least one character before that suffix.
Boundary reminders
Only lowercase letters, plus,dot and @ occur. Domain names end in .com and have at least one character before that suffix.