Skip to content

70_Climb_Stairs#7

Open
Yorkio wants to merge 1 commit intomasterfrom
reviewW2Pr3
Open

70_Climb_Stairs#7
Yorkio wants to merge 1 commit intomasterfrom
reviewW2Pr3

Conversation

@Yorkio
Copy link
Owner

@Yorkio Yorkio commented Oct 26, 2016

No description provided.

/*
n - number of stair levels.
Time Complexity T = O(n).
Memory complexity M = O(n).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that M=O(n).


int curLevelWaysCount = 1, prevLevelWaysCount = 1;
for (int level = 2; level <= n; ++level) {
curLevelWaysCount += prevLevelWaysCount;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not readable/clear. Use tmp variable to store the sum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants