Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 471 Bytes

831.md

File metadata and controls

27 lines (18 loc) · 471 Bytes

Masking Personal Information

Description

link


Solution

  • See Code

Code

O(n)

class Solution:
    def maskPII(self, S: str) -> str:
        at = S.find('@')
        if at >= 0:
            return (S[0] + "*" * 5 + S[at - 1:]).lower()
        S = "".join(i for i in S if i.isdigit())
        return ["", "+*-", "+**-", "+***-"][len(S) - 10] + "***-***-" + S[-4:]