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 a6e115a commit 0a06058Copy full SHA for 0a06058
Easy/Slowest Key.java
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ public char slowestKey(int[] releaseTimes, String keysPressed) {
3
+ int maxReleaseTime = 0;
4
+ int maxReleaseTimeIdx = 0;
5
+ for (int idx = 0; idx < releaseTimes.length; idx++) {
6
+ int currentIdx = keysPressed.charAt(idx) - 'a';
7
+ int currReleaseTime = releaseTimes[idx] - (idx == 0 ? 0 : releaseTimes[idx - 1]);
8
+ if (currReleaseTime >= maxReleaseTime) {
9
+ if (currReleaseTime > maxReleaseTime) {
10
+ maxReleaseTimeIdx = currentIdx;
11
+ } else if (currentIdx > maxReleaseTimeIdx) {
12
13
+ }
14
+ maxReleaseTime = currReleaseTime;
15
16
17
+ return (char) (97 + maxReleaseTimeIdx);
18
19
+}
0 commit comments