bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumMath & GeometryLC 831

Masking Personal Information

You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules. Email address: An email address is: A name consisting of uppercase and lowercase English letters, followed by The '@' symbol, followed by The domain consisting of uppercase and lowercase English letters with a dot '.' somewhere in the middle (not the first or last character). To mask an email: The uppercase letters in the name and domain must be converted to lowercase letters. The middle letters of the name (i.e., all but the first and last letters) must be replaced by 5 asterisks "* ". Phone number: A phone number is formatted as follows: The phone number contains 10-13 digits.

Asked at 1 company
Twitter
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode