Stock Buy Sell Position Indicator

Problem Overview

  • Compute a running position by applying buy (+1) and sell (-1) signals when indicator patterns match price movements.
  • Input: integer prices and buyIndicator/sellIndicator arrays of 1 or -1; Output: positions list equal in length; equal prices do not trigger; both indicators can match with net 0.
  • Models stock trading signal detection from price change sequences.
  • An interview question from Hudson_river interviews, typical of a coding interview problem.

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: