Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

121. Best Time to Buy and Sell Stock #21

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

Merged
zwfang merged 1 commit into master from best-time-to-buy-and-sell-stock
Dec 28, 2018

Conversation

Copy link
Collaborator

@zwfang zwfang commented Dec 28, 2018

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

Say you have an array for which the ith element is the price of a given stock on day i.

If you were only permitted to complete at most one transaction
(i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.

Note that you cannot sell a stock before you buy one.

Copy link

codecov bot commented Dec 28, 2018
edited
Loading

Codecov Report

Merging #21 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@
## master #21 +/- ##
==========================================
+ Coverage 99.09% 99.11% +0.02% 
==========================================
 Files 62 63 +1 
 Lines 1091 1115 +24 
==========================================
+ Hits 1081 1105 +24 
 Misses 6 6 
 Partials 4 4
Impacted Files Coverage Δ
.../0121_best_time_to_buy_and_sell_stock/maxprofit.go 100% <100%> (ø)

@zwfang zwfang added array An array is stored such that the position of each element can be computed from its index Easy Coefficient of difficulty easy dynamic programming optimal substructure and overlapping sub-problem are two key attributes for dynamic programming. labels Dec 28, 2018
@zwfang zwfang merged commit a231349 into master Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
array An array is stored such that the position of each element can be computed from its index dynamic programming optimal substructure and overlapping sub-problem are two key attributes for dynamic programming. Easy Coefficient of difficulty easy
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /