Calculate Maximum Quality Score (Fungible :)

Problem Overview

  • Determine the maximum qualityScore (max sum of any consecutive ratings) after applying exactly one strategy.
  • Inputs: ratings array and impactFactor; choose one contiguous segment to multiply by impactFactor or divide by impactFactor (floor positives, ceil negatives); output a long.
  • Real-world context: eco-friendly product ratings on Amazon, balancing quality and environmental impact.
  • Constraints: 1 <= n <= 2e5, 1 <= impactFactor <= 1e4, ratings[i] in [-1e5, 1e5].
  • From Amazon interviews; a coding interview problem and interview question.

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: