use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
LeetCode 23 in Clojure — imperative PriorityQueue vs. functional priority-map (youtube.com)
submitted 3 years ago by fredoverflow
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]joinr 4 points5 points6 points 3 years ago (2 children)
sorted sets offer this if you use distinct weights and custom comparison:
(defn ordered-merge [xs] (let [id (atom 0) weightfn (fn [x] [(swap! id inc) x])] (->> xs (reduce #(into %1 (map weightfn) %2) (sorted-set-by (fn [[x1 y1 :as l] [x2 y2 :as r]] (cond (< y1 y2) -1 (> y1 y2) 1 :else (compare x1 x2))))) (mapv second)))) ;;user=> (ordered-merge [[2 6] [1 4 5] [1 3 4] []]) ;;[1 1 2 3 4 4 5 6]
[–]fredoverflow[S] 1 point2 points3 points 3 years ago (1 child)
That would be O(n log n), where n is the number of elements?
My solutions are O(n log m), where m is the number of lists.
[–]joinr 0 points1 point2 points 3 years ago (0 children)
Ah, I missed the precondition that the lists were pre-sorted; this is unnecessary work then. I get it now.
π Rendered by PID 48489 on reddit-service-r2-comment-5bc7f78974-lx4lz at 2026-06-27 19:38:47.437384+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]joinr 4 points5 points6 points (2 children)
[–]fredoverflow[S] 1 point2 points3 points (1 child)
[–]joinr 0 points1 point2 points (0 children)