#### Approach #1: Direct [Accepted]

Intuition and Algorithm

We perform the algorithm as described.

First, to check if information is an email, we check whether it contains a '@'. (There are many different tests: we could check for letters versus digits, for example.)

If we have an email, we should replace the first name with the first letter of that name, followed by 5 asterisks, followed by the last letter of that name.

If we have a phone number, we should collect all the digits and then format it according to the description.

Complexity Analysis

• Time Complexity: , if we consider the length of S as bounded by a constant.

• Space Complexity: .

Analysis written by: @awice.