Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getProfit(list: number[]): number {
- const maxProfitForEach: number[] = [];
- list.forEach((cost: number, index: number) => {
- const nextDays = list.slice(index);
- const maxCost = Math.max.apply(null, nextDays);
- maxProfitForEach.push(maxCost - cost);
- });
- return Math.max.apply(null, maxProfitForEach);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement