aboutsummaryrefslogtreecommitdiff
path: root/racket/leetcode/lc-1299-replace-with-greatest-to-right.rkt
blob: 34d3eae6cc87996b934d4e6ac694efa812d29abf (plain)
1
2
3
4
5
6
7
8
#lang racket
(define/contract (replace-elements arr)
  (-> (listof exact-integer?) (listof exact-integer?))
  (cond [(= 1 (length arr)) '(-1)]
        [else (cons (apply max (cdr arr))
                    (replace-elements (cdr arr)))]))

(replace-elements '(17 18 5 4 6 1))