Given Scheduler time and its cooldown period, compute total time to complete all schedulers.
ex. [1,2,2,2,1,2]
2
1 2 _ _ 2 _ _ 2 1 _ 2
3
1 2 _ _ _ 2 _ _ _ 2 1 _ _ 2
[1,2,2,3,4,5,1]
2
1 2 _ _ 2 3 4 5 1
3
1 2 _ _ _ 2 3 4 5 1
[1,2,2,1]
2
1 2 _ _ 2 1
3
1 2 _ _ _ 2 1
[1,2,1,2,1,2,1,2]
2
1 2 _ 1 2 _ 1 2 _ 1 2
3
1 2 _ _ 1 2 _ _ 1 2 _ _ 1 2
'''
inpt = [1,2,2,2,1,2]
# 2 -> 11 3 -> 14
inpt = [1,2,2,3,4,5,1]
# 2 -> 9 3 -> 10
inpt = [1,2,2,1]
# 2 -> 6 3 -> 7
inpt = [1,2,1,2,1,2,1,2]
# 2 -> 11 3 -> 14
mp = {}
total = 0
cooldown = 3
for index,number in enumerate(inpt):
total += 1
if number in mp:
prev_index = mp[number]
if total - prev_index > cooldown:
pass
else:
total += (cooldown - (total - prev_index) + 1)
mp[number] = total
else:
mp[number] = total
print("total : ",total)