Skip to content
Back to libraryPart 2 · Core techniques

2.2Two pointers

Before you start

It helps to have read 1.5 Sorting and 2.1 Prefix sums. Overall level: Core.

Practice: Two pointers

0 of 4 solved

About these problems

Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.

  1. 1Target pairDetermine whether two different positions in a nondecreasing array sum to x.ApplyNot started
  2. 2Longest affordable runFind the greatest length of a consecutive block whose sum is at most k. All values are positive. Print 0 if no nonempty block fits.ConnectNot started
  3. 3Count affordable runsCount all nonempty consecutive blocks whose sum is at most k. All values are positive.ReasonNot started
  4. 4At most k signalsFind the longest consecutive block containing at most k distinct values.StretchNot started

Read the lesson