Skip to content

Commit

Permalink
[10_recursive] one_two_step, applying iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam0205 committed Oct 12, 2018
1 parent d458314 commit 07297f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions c-cpp/10_recursive/one_two_step.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class SolutionOFOneTwoStep {

public:
size_t operator()(size_t steps) {
if (result_.end() != result_.find(steps)) {
return result_[steps];
auto iter = result_.find(steps);
if (result_.end() != iter) { // found.
return iter->second;
} else {
size_t res = operator()(steps - 1) + operator()(steps - 2);
result_.insert({steps, res});
Expand Down

0 comments on commit 07297f8

Please sign in to comment.