Skip to content

Commit 53d7520

Browse files
committed
num-is-palindrome
1 parent 7ebf7dc commit 53d7520

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: main.rkt

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(require "reverse-integer.rkt")
99
(require "length-of-last-word.rkt")
1010
(require "first-missing-positive.rkt")
11+
(require "num-is-palindrome.rkt")
1112

1213
(check-equal? (two-sum 5 '(1 2 3 4)) '(1 2))
1314
(check-equal? (two-sum 21 '(0 2 11 19 90)) '(1 3))
@@ -35,3 +36,7 @@
3536
(check-equal? (first-missing-positive '(1 2 0)) 3)
3637
(check-equal? (first-missing-positive '(3 4 -1 1)) 2)
3738
(check-equal? (first-missing-positive '(7 8 9 11 12)) 1)
39+
40+
(check-equal? (num-is-palindrome 121) #t)
41+
(check-equal? (num-is-palindrome -121) #f)
42+
(check-equal? (num-is-palindrome 10) #f)

Diff for: num-is-palindrome.rkt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#lang racket
2+
3+
(define (num-is-palindrome num)
4+
"https://leetcode.com/problems/palindrome-number/"
5+
(define num-list (string->list (number->string num)))
6+
(equal? (reverse num-list) num-list))
7+
8+
(provide num-is-palindrome)

0 commit comments

Comments
 (0)