Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profit From Trading Stocks

Maximum Profit From Trading Stocks gives current and future prices for each stock and a budget. Choose each stock at most once within the budget to return the greatest total profit.

Statement

You are given two 00 indexed integer arrays present and future of length n, where present[i] is the current price of the ithi^{ {th}} stock and future[i] is the anticipated future price of the ithi^{ {th}} stock. You are also given an integer budget.

You may buy each stock at most once, and the total cost to buy the chosen stocks cannot exceed budget.

Return the maximum profit that can be achieved.

Constraints:

  • n ==== present.length ==== future.length

  • 1≤1 \leq n ≤1000\leq 1000

  • 0≤0 \leq present[i], future[i] ≤100\leq 100

  • 0≤0 \leq budget ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profit From Trading Stocks

Maximum Profit From Trading Stocks gives current and future prices for each stock and a budget. Choose each stock at most once within the budget to return the greatest total profit.

Statement

You are given two 00 indexed integer arrays present and future of length n, where present[i] is the current price of the ithi^{ {th}} stock and future[i] is the anticipated future price of the ithi^{ {th}} stock. You are also given an integer budget.

You may buy each stock at most once, and the total cost to buy the chosen stocks cannot exceed budget.

Return the maximum profit that can be achieved.

Constraints:

  • n ==== present.length ==== future.length

  • 1≤1 \leq n ≤1000\leq 1000

  • 0≤0 \leq present[i], future[i] ≤100\leq 100

  • 0≤0 \leq budget ≤1000\leq 1000