From 3962f30539391c579f65ae5dbf853d90b6b34bea Mon Sep 17 00:00:00 2001 From: Matuush Date: Wed, 9 Apr 2025 14:12:41 +0200 Subject: [PATCH] Support inserting a treap into another --- treap.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/treap.hpp b/treap.hpp index 425c4ac..e415516 100644 --- a/treap.hpp +++ b/treap.hpp @@ -110,6 +110,12 @@ public: two.first = join(two.first, l); root = join(two); } + void insert(int k, treap t) { + // TODO test + auto two = split(root, k); + two.first = join(two.first, t.root); + root = join(two.first, two.second); + } void append(string s) { insert(size(), s); }