Skip to content

Commit a0dac32

Browse files
authored
Update index.ts
1 parent 364c64d commit a0dac32

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

climbing-stairs/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// My code goes here
22
/** https://leetcode-cn.com/problems/climbing-stairs */
3-
export default function climbStairs(n: number): number {
4-
return Number(getClimbStairs(BigInt(n)));
3+
export default function climbStairs(n: number): number| bigint {
4+
const result = getClimbStairs(BigInt(n));
5+
if (result < Number.MAX_SAFE_INTEGER) {
6+
return Number(result);
7+
} else {
8+
return result;
9+
}
510
}
611

712
function getClimbStairs(num: bigint): bigint {

0 commit comments

Comments
 (0)