Maximum Valid Pair Sum
Pick two positions at least k apart and maximise their sum. Walking the right end forward while tracking the best value that is allowed to pair with it keeps the scan linear.
Pick two positions at least k apart and maximise their sum. Walking the right end forward while tracking the best value that is allowed to pair with it keeps the scan linear.