func LongestLightingTime(operation [][]int) byte {
if len(operation) == 1 {
return int2byte(operation[0][0])
}
var res int
var max int = operation[0][1]
for i := 1; i < len(operation); i++ {
if tmp := operation[i][1] - operation[i-1][1]; tmp >= max {
res = operation[i][0]
max = tmp
}
}
return int2byte(res)
}
func int2byte(num int) byte {
return byte(num + 97)
}
def longtime_light(light_time:list):
time=[light_time[0][1]]
light=[]
for i in range(1,len(light_time)):
a=light_time[i][1]-light_time[i-1][1]
time.append(a)
for i in range(len(light_time)):
b=light_time[i][0]
light.append(chr(97+b)) ##将数字转为小写字母
return light[time.index(max(time))]
def solution(operation: list) -> str:
tmp = []
res = []
tmp.append(operation[0])
for i in range(1, len(operation)):
time = operation[i][1]-operation[i-1][1]
# 考虑并列第一的情况
if tmp[0][1] == time and [operation[i][0], time] not in tmp:
tmp.append([operation[i][0], time])
elif tmp[0][1] < time:
tmp.clear()
tmp.append([operation[i][0], time])
for i in tmp:
res.append(chr(97+i[0]))
return "".join(sorted(res))
assert solution([[0, 2], [1, 5], [0, 9], [2, 15], [0, 21], [0, 27]]) == 'ac'