Skip to content

Commit 7ebf7dc

Browse files
committed
first-missing-positie
1 parent 8b61631 commit 7ebf7dc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

first-missing-positive.rkt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#lang racket
2+
3+
(define (first-missing-positive nums)
4+
"https://leetcode.com/problems/first-missing-positive/"
5+
(foldl (lambda (num res) (if (= res num) (+ res 1) res)) 1 (sort nums <)))
6+
7+
(provide first-missing-positive)

main.rkt

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(require "count-upper.rkt")
88
(require "reverse-integer.rkt")
99
(require "length-of-last-word.rkt")
10+
(require "first-missing-positive.rkt")
1011

1112
(check-equal? (two-sum 5 '(1 2 3 4)) '(1 2))
1213
(check-equal? (two-sum 21 '(0 2 11 19 90)) '(1 3))
@@ -30,3 +31,7 @@
3031
(check-equal? (length-of-last-word "Hello World") 5)
3132
(check-equal? (length-of-last-word "Hello ") 0)
3233
(check-equal? (length-of-last-word " ") 0)
34+
35+
(check-equal? (first-missing-positive '(1 2 0)) 3)
36+
(check-equal? (first-missing-positive '(3 4 -1 1)) 2)
37+
(check-equal? (first-missing-positive '(7 8 9 11 12)) 1)

0 commit comments

Comments
 (0)