From fafbeaf9e3c09ba7a5bea7e47d5736001f8a5aa1 Mon Sep 17 00:00:00 2001 From: HJ Date: Tue, 17 Jan 2023 12:46:04 -0500 Subject: adding old leetcode solutions --- leetcode/lc-953-alien-dictionary.rkt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 leetcode/lc-953-alien-dictionary.rkt (limited to 'leetcode/lc-953-alien-dictionary.rkt') diff --git a/leetcode/lc-953-alien-dictionary.rkt b/leetcode/lc-953-alien-dictionary.rkt new file mode 100644 index 0000000..f72a895 --- /dev/null +++ b/leetcode/lc-953-alien-dictionary.rkt @@ -0,0 +1,26 @@ +#lang racket + +(define/contract (is-alien-sorted words order) + (-> (listof string?) string? boolean?) + (define alpha-order + (make-hash (map (λ (a b) (cons a b)) + (map string (string->list order)) + (build-list (string-length order) identity)))) + (hash-set! alpha-order #\* -1) + (define (alien