Count Arithmetic Triples After Stream Operations

Given an integer diff and an initially empty integer multiset, process q stream operations in order:

  • + x: insert one occurrence of value x.
  • - x: remove all occurrences of value x ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: