Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profit From Trading Stocks

Try to solve the Maximum Profit From Trading Stocks problem.

Statement

You are given two 00 indexed integer arrays present and future of length n, where present[i] is the current price of the iextthi^{ ext{th}} stock and future[i] is the anticipated future price of the iextthi^{ ext{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

Try to solve the Maximum Profit From Trading Stocks problem.

Statement

You are given two 00 indexed integer arrays present and future of length n, where present[i] is the current price of the iextthi^{ ext{th}} stock and future[i] is the anticipated future price of the iextthi^{ ext{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