We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8f11b7e commit a2af62bCopy full SHA for a2af62b
Python/slowest-key.py
@@ -0,0 +1,19 @@
1
+# Time: O(n)
2
+# Space: O(1)
3
+
4
+import collections
5
6
7
+class Solution(object):
8
+ def slowestKey(self, releaseTimes, keysPressed):
9
+ """
10
+ :type releaseTimes: List[int]
11
+ :type keysPressed: str
12
+ :rtype: str
13
14
+ result, lookup = 'a', collections.Counter()
15
+ for i, c in enumerate(keysPressed):
16
+ lookup[c] = max(lookup[c], releaseTimes[i]-(releaseTimes[i-1] if i > 0 else 0))
17
+ if lookup[c] > lookup[result] or lookup[c] == lookup[result] and c > result:
18
+ result = c
19
+ return result
0 commit comments