hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

Šimon Tóth

Tuesday common C++ interview problem: Best time to buy and sell stock.

Given information about stock prices as std::vector<int> (each element represents the price at that time), determine the maximum possible profit with two transactions.

You can only hold one stock at a time and only do one buy or sell operation at each time.

Solve it yourself: compiler-explorer.com/z/ejn937
Solution: compiler-explorer.com/z/f3sT7a