American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

6 PM – Coding Olympic Training

February 14, 2022 @ 6:00 pm - 7:00 pm

Homework:

You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day.

Find and return the maximum profit you can achieve.

Input: prices = [7,1,5,3,6,4]

Output: 7

 

Bonus question:

For same background, find the maximum profit you can achieve. You may complete at most two transactions.

Details

Date:
February 14, 2022
Time:
6:00 pm - 7:00 pm
Verified by MonsterInsights