{"id":234,"date":"2018-11-14T19:46:57","date_gmt":"2018-11-14T11:46:57","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=234"},"modified":"2018-11-29T14:47:44","modified_gmt":"2018-11-29T06:47:44","slug":"929-unique-email-addresses","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=234","title":{"rendered":"929. Unique Email Addresses"},"content":{"rendered":"<p>Every email consists of a local name and a domain name, separated by the @ sign.<\/p>\n<p>For example, in\u00a0<code>alice@leetcode.com<\/code>,\u00a0<code>alice<\/code>\u00a0is the local name, and\u00a0<code>leetcode.com<\/code>\u00a0is the domain name.<\/p>\n<p>Besides lowercase letters, these emails may contain\u00a0<code>'.'<\/code>s or\u00a0<code>'+'<\/code>s.<\/p>\n<p>If you add periods (<code>'.'<\/code>) between some characters in the\u00a0<strong>local name<\/strong>\u00a0part of an email address, mail sent there will be forwarded to the same address without dots in the local name.\u00a0 For example,\u00a0<code>\"alice.z@leetcode.com\"<\/code>\u00a0and\u00a0<code>\"alicez@leetcode.com\"<\/code>\u00a0forward to the same email address.\u00a0 (Note that this rule does not apply for domain names.)<\/p>\n<p>If you add a plus (<code>'+'<\/code>) in the\u00a0<strong>local name<\/strong>, everything after the first plus sign will be\u00a0<strong>ignored<\/strong>. This allows certain emails to be filtered, for example\u00a0<code>m.y+name@email.com<\/code>\u00a0will be forwarded to\u00a0<code>my@email.com<\/code>.\u00a0 (Again, this rule does not apply for domain names.)<\/p>\n<p>It is possible to use both of these rules at the same time.<\/p>\n<p>Given a list of\u00a0<code>emails<\/code>, we send one email to each address in the list.\u00a0\u00a0How many different addresses actually receive mails?<\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input: <\/strong><span id=\"example-input-1-1\">[\"test.email+alex@leetcode.com\",\"test.e.mail+bob.cathy@leetcode.com\",\"testemail+david@lee.tcode.com\"]<\/span>\r\n<strong>Output: <\/strong><span id=\"example-output-1\">2<\/span>\r\n<strong>Explanation:<\/strong>\u00a0\"<span id=\"example-input-1-1\">testemail@leetcode.com\" and \"testemail@lee.tcode.com\" <\/span>actually receive mails\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li><code>1 &lt;= emails[i].length\u00a0&lt;= 100<\/code><\/li>\n<li><code>1 &lt;= emails.length &lt;= 100<\/code><\/li>\n<li>Each\u00a0<code>emails[i]<\/code>\u00a0contains exactly one\u00a0<code>'@'<\/code>\u00a0character.<\/li>\n<\/ul>\n<\/div>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def numUniqueEmails(self, emails):\r\n        &quot;&quot;&quot;\r\n        :type emails: List[str]\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        d = {}\r\n        for email in emails:\r\n            a = email.split(&quot;@&quot;)\r\n            b = a[0].split(&quot;+&quot;)\r\n            c = b[0].replace(&quot;.&quot;, &quot;&quot;)\r\n            d[c+a[1]] = 1\r\n        return len(d)\r\n        \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Every email consists of a local name and a domain name,<a href=\"https:\/\/www.ccagml.com\/?p=234\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">929. Unique Email Addresses<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/234"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=234"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/234\/revisions"}],"predecessor-version":[{"id":235,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/234\/revisions\/235"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}