Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 831. Masking Personal Information
Given a string that's either an email or a phone number, detect which it is and return a masked version: for emails, convert to lowercase and replace the name's middle characters with exactly five asterisks, preserving the first and last letters and the domain; for phone numbers, strip non-digit characters (10–13 digits), treat the last 10 as the local number and format as XXXX for the last four digits with the preceding parts replaced by *** groups and a + followed by 0–3 asterisks for the country code.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.