2
def longestWPI(self, hours: List[int]) -> int:4
# +1 when > 8, -1 when less than 8.5
# find strictly increasing length.7
p = [] # number of tiring days vs not17
# for every moment: we want earliest moment which could be positive overall tiring days.19
# a is sorted by tiringnes. At day 8 have -2, want earliest point that could get us to at least 1.20
# so up until that point we have -3, -4, etc, and we want earliest out of it to get longest well performing interval. Which is when prefix comes in.23
for i in range(len(p)):27
a1.sort() # bisectable list31
currearly = float("inf")33
currearly = min(currearly, day)34
prefix.append(currearly)40
for i in range(len(hours)):46
# value must be less than -1-p[i]49
) # bisect right means anything before this is less than or equals to51
if loc == 0: # the rightmost place to put it is at the beginning...56
earliest = prefix[loc - 1]63
) # notice: we're not including the starting index, since its also technically being removed!65
# print("From day", earliest, "to", i)67
res = max(res, interval)