Skip to main content
All Questions

Given a day's buy and sell orders for one stock as (amount, time) pairs, with the position starting and ending at 0, compute the average time a share is held.

Unlock detailed company stats for this questionUpgrade
For one account and one stock you are given a day's list of buy and sell orders as (amount, time) pairs. The position starts at 0, ends at 0 and may go negative in between. Write code that computes the average time for which a share is held.

Community answers

No answers contributed by the community yet.

Related courses

Course

SQL Interview Prep Course

Prepare for SQL interviews with lessons on joins, aggregations, and window functions, then practice real SQL interview questions in an interactive editor with expert solutions.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.