Skip to content

Commit

Permalink
Update solution of Best Time to Buy and Sell Stock problem
Browse files Browse the repository at this point in the history
  • Loading branch information
dksifoua committed Jan 24, 2024
1 parent 68b9de1 commit fca7c88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/0121-Best-Time-to-Buy-and-Sell-Stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ After iterating through all the prices, `maxP` will hold the maximum profit achi

## Complexity

- **Time complexity: O(N)** where N is the number of days (the length of the `prices array). This is because it requires
- **Time complexity: O(N)** where N is the number of days (the length of the `prices` array). This is because it requires
a single pass through the array, checking each price once.
- **Space complexity: O(1)** since only a constant amount of extra space is used (for the variables `maxP`, `buy`,
and `sell`).

## Code

[Link](/src/main/java/io/dksifoua/leetcode/majorityelement/Solution.java)
[Link](/src/main/java/io/dksifoua/leetcode/besttimetobuyandsellstock/Solution.java)

## Summary

Expand Down

0 comments on commit fca7c88

Please sign in to comment.