java.lang.Object
g1601_1700.s1604_alert_using_same_key_card_three_or_more_times_in_a_one_hour_period.Solution

public class Solution extends Object
1604 - Alert Using Same Key-Card Three or More Times in a One Hour Period.<p>Medium</p> <p>LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker&rsquo;s name and the time when it was used. The system emits an <strong>alert</strong> if any worker uses the key-card <strong>three or more times</strong> in a one-hour period.</p> <p>You are given a list of strings <code>keyName</code> and <code>keyTime</code> where <code>[keyName[i], keyTime[i]]</code> corresponds to a person&rsquo;s name and the time when their key-card was used <strong>in a</strong> <strong>single day</strong>.</p> <p>Access times are given in the <strong>24-hour time format &ldquo;HH:MM&rdquo;</strong> , such as <code>&quot;23:51&quot;</code> and <code>&quot;09:49&quot;</code>.</p> <p>Return a <em>list of unique worker names who received an alert for frequent keycard use</em>. Sort the names in <strong>ascending order alphabetically</strong>.</p> <p>Notice that <code>&quot;10:00&quot;</code> - <code>&quot;11:00&quot;</code> is considered to be within a one-hour period, while <code>&quot;22:51&quot;</code> - <code>&quot;23:52&quot;</code> is not considered to be within a one-hour period.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> keyName = [&ldquo;daniel&rdquo;,&ldquo;daniel&rdquo;,&ldquo;daniel&rdquo;,&ldquo;luis&rdquo;,&ldquo;luis&rdquo;,&ldquo;luis&rdquo;,&ldquo;luis&rdquo;], keyTime = [&ldquo;10:00&rdquo;,&ldquo;10:40&rdquo;,&ldquo;11:00&rdquo;,&ldquo;09:00&rdquo;,&ldquo;11:00&rdquo;,&ldquo;13:00&rdquo;,&ldquo;15:00&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;daniel&rdquo;]</p> <p><strong>Explanation:</strong> &ldquo;daniel&rdquo; used the keycard 3 times in a one-hour period (&ldquo;10:00&rdquo;,&ldquo;10:40&rdquo;, &ldquo;11:00&rdquo;).</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> keyName = [&ldquo;alice&rdquo;,&ldquo;alice&rdquo;,&ldquo;alice&rdquo;,&ldquo;bob&rdquo;,&ldquo;bob&rdquo;,&ldquo;bob&rdquo;,&ldquo;bob&rdquo;], keyTime = [&ldquo;12:01&rdquo;,&ldquo;12:00&rdquo;,&ldquo;18:00&rdquo;,&ldquo;21:00&rdquo;,&ldquo;21:20&rdquo;,&ldquo;21:30&rdquo;,&ldquo;23:00&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;bob&rdquo;]</p> <p><strong>Explanation:</strong> &ldquo;bob&rdquo; used the keycard 3 times in a one-hour period (&ldquo;21:00&rdquo;,&ldquo;21:20&rdquo;, &ldquo;21:30&rdquo;).</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= keyName.length, keyTime.length <= 10<sup>5</sup></code></li> <li><code>keyName.length == keyTime.length</code></li> <li><code>keyTime[i]</code> is in the format <strong>&ldquo;HH:MM&rdquo;</strong>.</li> <li><code>[keyName[i], keyTime[i]]</code> is <strong>unique</strong>.</li> <li><code>1 <= keyName[i].length <= 10</code></li> <li><code>keyName[i] contains only lowercase English letters.</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details