Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022-10-08 #71

Open
github-actions bot opened this issue Oct 7, 2022 · 1 comment
Open

2022-10-08 #71

github-actions bot opened this issue Oct 7, 2022 · 1 comment

Comments

@github-actions
Copy link

github-actions bot commented Oct 7, 2022

No description provided.

@Akiq2016
Copy link

Akiq2016 commented Oct 8, 2022

/*
 * @lc app=leetcode.cn id=121 lang=java
 *
 * [121] 买卖股票的最佳时机
 */

// @lc code=start
class Solution {
    public int maxProfit(int[] prices) {
        int minPrice = prices[0];
        int result = 0;

        for (int price : prices) {
            minPrice = Math.min(minPrice, price);
            result = Math.max(result, price - minPrice);
        }

        return result;
    }
}
// @lc code=end

Nickname: Aki
From vscode-hzfe-algorithms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant