0
Leetcode Problem 831. Masking Personal Information
831. Masking Personal Information
AI Mock Interview
Leetcode Solutions
Masking Personal Information
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Check if the input string contains an '@' symbol to determine if it is an email.
If it is an email, split the string into name and domain using the '@' symbol.
Convert the entire email to lowercase.
Mask the name by keeping the first and last character and replacing the middle characters with five asterisks.
Concatenate the masked name, '@', and domain to form the masked email.
If it is a phone number, remove all non-digit characters.
Determine the length of the country code by subtracting 10 from the total length of digits.
Mask the last 10 digits as '
-
-XXXX'.
Prepend the country code mask based on its length (0, 1, 2, or 3 digits).
Return the masked phone number.
Regex-based Masking of Personal Information
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...