Qm
BrainteasersJane StreetCitadel

The optimist, the pessimist and the longest sequence

An optimist and a pessimist look at the same finite list of real numbers. The optimist says: "The sum of any eight consecutive terms is positive." The pessimist says: "The sum of any five consecutive terms is negative."

Can they both be right? If so, what is the longest list for which both statements can hold? Give an example of maximum length and prove nothing longer works.

Show a hint

Suppose there are 12 terms. Arrange them in a 5-row by 8-column table where the entry in row i, column j is the term in position i + j (numbering rows 0 to 4 and columns 1 to 8). Add up the table by rows, then by columns.

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

1, 1, 2, 5, 14, 42, what next?8, 5, 4, 9, 1, 7, 6, 3, 2, 0: what is the ordering?Empty one of three buckets by doubling poursThe fastest possible checkmateA domino tiling with no fault line
All questions →