Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions challenges/easy/palindrome-number/palindromeNumber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def is_palindrome_int(int1: int) -> bool:
int1 = str(int1)
int2 = int1

i = 0
j = len(int2) - 1

while j >= 0:
if int1[i] != int2[j]:
return False
i = i + 1
j = j - 1

return True
21 changes: 21 additions & 0 deletions challenges/easy/palindrome-number/palindromeNumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function is_palindrome_int (int: number) {

let i: number = 0;
let j: number = int.toString().length - 1;

while (j >= 0) {
if (int.toString()[i] !== int.toString()[j]) {
return false
}
i += 1;
j -= 1;
}

return true
}

console.log(is_palindrome_int(1010101)); // True
console.log(is_palindrome_int(101)); // True
console.log(is_palindrome_int(1101)); // False
console.log(is_palindrome_int(122)); // False
console.log(is_palindrome_int(-1101)); // False