Skip to content

Commit d2911cf

Browse files
authored
Merge pull request kodecocodes#886 from markgz/patch-1
The code of O(2^n) isn't correct which is O(n)
2 parents 6714e28 + 762de52 commit d2911cf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Big-O Notation.markdown

+2-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ Below are some examples for each category of performance:
124124
func solveHanoi(n: Int, from: String, to: String, spare: String) {
125125
guard n >= 1 else { return }
126126
if n > 1 {
127-
solveHanoi(n: n - 1, from: from, to: spare, spare: to)
128-
} else {
129-
solveHanoi(n: n - 1, from: spare, to: to, spare: from)
127+
solveHanoi(n: n - 1, from: from, to: spare, spare: to)
128+
solveHanoi(n: n - 1, from: spare, to: to, spare: from)
130129
}
131130
}
132131
```

0 commit comments

Comments
 (0)