I study computer sciene and I'm currently practising backtracking as I#m very bad at it. I found that exercise online:
You are selling apples. This is a current price tables for your apples:
Count 1 2 3 4 5 6 7 8 Price 1 5 8 9 10 17 17 20
So if you're selling 8 apples at once, you'll get 20$. If you're selling 6 and then 2 instead, you'll get 22$. Try to find the maximum profit. Here's the method, you should use:
public static long sellApples(int count, long[] prices) {
}
Now I thought about that like 5 hours, but I can't come to a good solution. Anyone up for a little challenge?