Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

LeetCode-Style Coding Range

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is LeetCode-Style Coding Range. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Citadel Securities evaluates candidate trading strategy windows, where each window has a start time, end time, and expected value. Select at most k non-overlapping windows to maximize total value.

Two windows are compatible when the earlier window's end time is less than or equal to the later window's start time. Return the maximum total value.

Formal Specification

Implement max_strategy_value(intervals, k), where intervals is a list of [start, end, value] integer records. Return an integer representing the maximum achievable value using at most k intervals.

Constraints

  • 1 <= len(intervals) <= 2 * 10^5
  • 1 <= k <= 100
  • 0 <= start < end <= 10^9
  • 1 <= value <= 10^9
  • Intervals with end == start are compatible

Function Signature

def max_strategy_value(intervals, k):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output