Created
January 12, 2021 03:53
-
-
Save corehello/e7f97828371b798ed8404210392cb99a to your computer and use it in GitHub Desktop.
yet another solution for https://leetcode.com/problems/climbing-stairs/ without fibonacci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import floor | |
from functools import reduce | |
from operator import mul | |
class Solution: | |
def climbStairs(self, n: int) -> int: | |
ret_sum = 0 | |
for i in range(0, floor(n/2)+1): | |
if i == 0: | |
ret_sum += 1 | |
continue | |
ret_sum += int(reduce(mul, range(n-i,n-i-i, -1), 1) / reduce(mul, range(1, i+1), 1)) | |
return ret_sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment