Leetcode 2145. Count the Hidden Sequences
Given consecutive differences of a hidden length-(n+1) sequence, compute its prefix sums to find the relative min and max offsets and then count how many integer starting values x keep every element within [lower, upper]. Equivalently, the answer is max(0, upper - lower - (maxPrefix - minPrefix) + 1), where maxPrefix/minPrefix are the max/min of the prefix sums (including 0).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.