Count Groups

Problem Overview

  • Given an array of cable tags, for each query [l, r] count how many disjoint pairs of equal tags exist in the subarray.
  • Input: tags and list of queries; Output: array of counts per query; each group is two cables; each cable used at most once; queries independent.
  • Real-world context: Twilio IT distributing USB cables labeled by type tags.
  • From Twilio interviews; a coding interview problem and interview question; constraints unspecified.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: