char slowestKey(int* releaseTimes, int releaseTimesSize, char * keysPressed){
char ans = keysPressed[0];
int maxTime = releaseTimes[0];
for (int i = 1; i < releaseTimesSize; i++) {
char key = keysPressed[i];
int time = releaseTimes[i] - releaseTimes[i - 1];
if (time > maxTime || (time == maxTime && key > ans)) {
ans = key;
maxTime = time;
}
}
return ans;
}
计算持续时间=当前时间-前一位时间
字母顺序排列,只要满足两个条件即可:
1.持续时间最长
2.如果持续时间相等就比较字符串大小