Skip to content

Commit 4762f42

Browse files
committed
Runtime 3 ms (Top 45.31%) | Memory 6.0 MB (Top 92.19%)
1 parent 2b4be92 commit 4762f42

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
// Runtime: 3 ms (Top 40.48%) | Memory: 6.1 MB (Top 73.81%)
2-
31
class Solution {
42
public:
53
string email(string &s, int id){
64
string t = string(1, s[0] | ' ') + "*****" + string(1, s[id-1] | ' ');
7-
8-
for(int i = id + 1; i != s.size(); i++)
5+
6+
for(int i = id + 1; i != s.size(); i++)
97
if(s[i] != '.') s[i] |= ' ';
10-
8+
119
return t + s.substr(id, s.size());
1210
}
13-
11+
1412
string phone(string &s){
1513
string table[] = { "" , "+*-", "+**-", "+***-" }, t;
16-
14+
1715
for(auto &ch: s)
1816
if(ch >= '0' && ch <= '9') t.push_back(ch);
19-
17+
2018
return table[t.size() - 10] + "***-***-" + t.substr(t.size() - 4, 4);
2119
}
22-
20+
2321
string maskPII(string s) {
24-
int id = s.find('@');
22+
int id = s.find('@');
2523
return id == -1 ? phone(s) : email(s, id);
2624
}
2725
};

0 commit comments

Comments
 (0)