Skip to content

Commit 8b61631

Browse files
committed
length of last word
1 parent 772ca01 commit 8b61631

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

length-of-last-word.rkt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#lang racket
2+
3+
(define (length-of-last-word words)
4+
"https://leetcode.com/problems/length-of-last-word/"
5+
(if (string-suffix? words " ") 0 (string-length (last (string-split words " ")))))
6+
7+
(provide length-of-last-word)

main.rkt

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
(require "remove-dups.rkt")
77
(require "count-upper.rkt")
88
(require "reverse-integer.rkt")
9+
(require "length-of-last-word.rkt")
910

1011
(check-equal? (two-sum 5 '(1 2 3 4)) '(1 2))
1112
(check-equal? (two-sum 21 '(0 2 11 19 90)) '(1 3))
@@ -25,3 +26,7 @@
2526
(check-equal? (reverse-integer 123) 321)
2627
(check-equal? (reverse-integer -123) -321)
2728
(check-equal? (reverse-integer 120) 21)
29+
30+
(check-equal? (length-of-last-word "Hello World") 5)
31+
(check-equal? (length-of-last-word "Hello ") 0)
32+
(check-equal? (length-of-last-word " ") 0)

0 commit comments

Comments
 (0)