CLIMBING STAIRS
https://leetcode.com/problems/climbing-stairs/
You are climbing a staircase. It takes n
 steps to reach the top.
Each time you can either climb 1
 or 2
 steps. In how many distinct ways can you climb to the top?
Â
Example 1:
Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps
Example 2:
Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2. 1 step + 2 steps 3. 2 steps + 1 step
Â
Constraints:
1 <= n <= 45
SOLUTION USING TYPESCRIPT
function climbStairs(nums: number) {
 let one = 1;
 let two = 1;
 for (let i = nums - 1; i > 0; i--) {
  let temp = one;
  [one, two] = [one + two, temp];
 }
 return one;
}
PALLINDROME NUMBER
https://leetcode.com/problems/palindrome-number/
Given an integer x
, return true
 if x
 is palindrome integer.
An integer is a palindrome when it reads the same backward as forward.
- For example,Â
121
 is a palindrome whileÂ123
 is not.
Example 1:
Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:
Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3:
Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Constraints:
-231Â <= x <= 231Â - 1
SOLUTION USING TYPESCRIPT
function isPalindrome(x: number) {
 if (x < 0) return false;
 let y = x.toString();
 for (let i = 0; i < y.length / 2; i++) {
  if (y[i] !== y[y.length - 1 - i]) return false;
 }
 return true;
}
Submission Detail
11510 / 11510Â test cases passed. | Status:Â Accepted |
Runtime:Â 215 ms Memory Usage:Â 51.9 MB | Submitted:Â 3Â months ago |