We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bf5bc96 + 692e70a commit b1a7c5cCopy full SHA for b1a7c5c
1 file changed
C#/ChatGPT/ImmutableBinaryTree.cs
@@ -30,4 +30,16 @@ public ImmutableBinaryTree<T> ReplaceRight(ImmutableBinaryTree<T>? newRight)
30
{
31
return new ImmutableBinaryTree<T>(Value, Left, newRight);
32
}
33
+
34
+ // Replace the root value but keep structure
35
+ public ImmutableBinaryTree<T> ReplaceRootValue(T newValue)
36
+ {
37
+ return new ImmutableBinaryTree<T>(newValue, Left, Right);
38
+ }
39
40
+ // Example Insert pattern: replace root on match
41
+ public ImmutableBinaryTree<T> InsertAtRoot(T newValue)
42
43
+ return ReplaceRootValue(newValue);
44
45
0 commit comments