Practice Masking Personal Information
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Mask s, which is a valid email address or phone number. For an email, lowercase the whole address and replace all letters between the first and last letters of the name before @ with exactly five asterisks; keep the domain. An email name has at least two letters. For a phone number, discard separators +, -, parentheses and spaces. There are 10 through 13 digits: the last ten form the local number and any earlier digits form its country code. Keep only the last four digits. With no country code, return ***-***-XXXX. With one, two or three country-code digits, prepend +*-, +**- or +***- respectively to that local masked form.
Source: Masking Personal Information on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "LeetCode@LeetCode.com"
"l*****e@leetcode.com"
# Example 2
s = "AB@qq.com"
"a*****b@qq.com"
# Example 3
s = "1(234)567-890"
"***-***-7890"
Constraints
Related LeetCode Problems
Practice more problems similar to Masking Personal Information.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.