Questions tagged [maximum-profit-problem]
20 questions
5
votes
3 answers
Interval Scheduling Algorithm or Activity Selection Algorithm
I'm struggling with this question for so long.
There are n persons who want same room in a hotel. Each person wants to stay in the hotel for his own convenient time but only one person can stay at a time. Assume that room is available from 5AM to…

Parag Tyagi
- 8,780
- 3
- 42
- 47
3
votes
1 answer
Maximising stock profit given multiple stocks
I have looked into stock profit maximising algorithms depending on the situation.
Strategies for situations where you only have one stock and can either buy/sell once or multiple times are clear to me. You use greatest difference and maximum sub…

Django
- 343
- 1
- 4
- 23
2
votes
1 answer
maximize profit through trading
I have been stuck on this question for a while trying to figure out the recurrence relationship for the following problem.
Problem description:
Suppose in a market the following trade options are possible:
1 metal to 2 wood
1 wood to 0.2 glass
1…

tempNULL
- 23
- 3
1
vote
2 answers
Interview Question - Find the Max difference of Two elements in the Array in less than O(n^2) - the Lower element should precede the Greater element
During an interview, I've been asked the following Question:
You're given an array of integer numbers.
Find the maximum difference between two elements arr[j] - arr[i]
for any sub array in the array, so that j>i.
For example:
array =…

namrata agarwal
- 31
- 6
1
vote
1 answer
not sure why this solution is returning undefined (array algo)
the problem is as follows :
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm…

st123
- 246
- 3
- 14
1
vote
1 answer
Other multi value optimisation using brute force search?
I've 6 list of company possible orders (a,b,c,d,e,f) in dollars.The price changes every week (13 weeks) as below.
a1_list = [1075000, 1075000, 1072500, 1072500, 1070000, 1070000, 1050000, 1535000, 1535000, 1015000, 1015000, 1000000,…

JamesAng
- 344
- 2
- 9
1
vote
0 answers
How to optimize events scheduling with unknown future events?
Scenario:
I need to give users opportunity to book different times for the service.
Caveat is that i dont have bookings in advance but i need to fill them as they come in.
Bookings can be represented as keyvalue pairs:
[startTime, duration]
So, for…

dee zg
- 13,793
- 10
- 42
- 82
1
vote
1 answer
Optimal assignment to maximize output
So a company has n available projects and k employees on the bench. Each project has a "number of hours" associated with it. Each employee has an hourly rate that the parent company gets paid gets paid if he is on a project. Not all employees can be…

user2995244
- 25
- 5
1
vote
1 answer
Given an array of time and selling price find the best buying and selling time to maximize the profit
Given [ (02:00, 7.5), (03:30, 7.9), (04:00, 8.0), (05:30, 6.8), (10:00, 9.01)] times and selling price we need to find the best time for buying and selling to maximize the profit.
// times are in increasing order
// Sample Output: Buy at 05:30 and…

Praveen Mulchandani
- 426
- 5
- 15
0
votes
0 answers
maximum net profit for a variable range
I am trying to display maximum strategy.netprofit for a range of a variable (l1). It is not displaying maximum value of the strategy netprofit but is changing with max value of l1 (l1MaxIn).
Is there a simpler way to achieve this?
Thank…

george
- 1
- 1
0
votes
2 answers
Is there a neat way to get hold of the number of times pine script strategy.exit has reached limit profit (maxprofit)?
I would like to find a way on how to track the number of times that the below strategy has taken maxProfit. The idea is to stop the strategy to run once, we hit certain number of maxProfit.
strategy.exit(id="XL STP", profit = maxProfit, loss =…

AitchGee
- 1
- 1
0
votes
2 answers
How can I find the optimal price for each time t in R?
I have the price range price <- c(2.5,2.6,2.7,2.8)
and my dataset have several time t. For each time t, I have a corresponding cost c and demand quantity d.
I need to find the optimal price for each time t to maximise my required profit function…

Tiffany Guo
- 1
- 1
0
votes
2 answers
Interview Question: Maximize stock profits
So I came across this question during an interview and was unable to solve it. Hopefully, someone can advise. The problem is this.
Imagine you have S amounts of savings in integers. You are thinking of buying stocks. Someone has provided you with 2…

David Yao
- 107
- 8
0
votes
0 answers
Most Profit Assigning Work Problem from Leetcode (Problem no. 826)
I have been trying to solve this problem on leetcode (https://leetcode.com/problems/most-profit-assigning-work/) whose problem description goes like this :
We have jobs: difficulty[i] is the difficulty of the ith job, and
profit[i] is the profit of…

Soubhagya Akkena
- 1
- 2
0
votes
1 answer
How to achieve shortsell condition in this stock profit maximisation code?
This is the code I have written to buy the stock when the price is lowest and sell when it is max. I want to implement shortsell condition here like I want to sell even before buying.
Consider this array of stock prices for a week.
3 10 4 1 9 3…

Shubham Thakur
- 3
- 4