Skip to content

Commit ad6c40f

Browse files
authored
Merge pull request neetcode-gh#443 from Sinha1994/main
Solution for 9 - Palindrome Number in TypeScript
2 parents bff0c73 + cb4aa14 commit ad6c40f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

typescript/9-Palindrom-Number.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var isPalindrome = (x: number) => {
2+
// Creates array from int characters
3+
// 121 -> [1,2,1]
4+
let arr = Array.from(String(x), Number);
5+
6+
// Uses two pointer
7+
for (let i = 0; i < arr.length; i++) {
8+
if (arr[i] !== arr[arr.length - 1 - i]) {
9+
return false;
10+
}
11+
}
12+
return true;
13+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy