mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Fix four typos (#1139)
This commit is contained in:
@@ -46,7 +46,7 @@ Let's say we have an array of prices `[7, 6, 4, 3, 1]` and we're on the _1st_ da
|
||||
1. _Option 1: Keep the money_ → profit would equal to the profit from buying/selling the rest of the stocks → `keepProfit = profit([6, 4, 3, 1])`.
|
||||
2. _Option 2: Buy/sell at current price_ → profit in this case would equal to the profit from buying/selling the rest of the stocks plus (or minus, depending on whether we're selling or buying) the current stock price → `buySellProfit = -7 + profit([6, 4, 3, 1])`.
|
||||
|
||||
The overall profit would be equal to → `overalProfit = Max(keepProfit, buySellProfit)`.
|
||||
The overall profit would be equal to → `overallProfit = Max(keepProfit, buySellProfit)`.
|
||||
|
||||
As you can see the `profit([6, 4, 3, 1])` task is being solved in the same recursive manner.
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ and return false.
|
||||
queen here leads to a solution.
|
||||
b) If placing queen in [row, column] leads to a solution then return
|
||||
true.
|
||||
c) If placing queen doesn't lead to a solution then umark this [row,
|
||||
c) If placing queen doesn't lead to a solution then unmark this [row,
|
||||
column] (Backtrack) and go to step (a) to try other rows.
|
||||
3) If all rows have been tried and nothing worked, return false to trigger
|
||||
backtracking.
|
||||
|
||||
Reference in New Issue
Block a user