DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Trade Signal

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
L4

Problem

Given a list of prices, find the max gain of a single buy-then-sell window. Return a 3-element list [gain, buy_day_index, sell_day_index]. If no profit is possible (gain <= 0), return [0, 0, 0]. Among multiple windows tied for max gain, return the one with the earliest buy index then earliest sell index.

Summary

Buy low, sell high. Identify the ideal moment.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons