PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 146
Good morning! Here's your coding interview problem for today.

This question was asked by BufferBox.

Given a binary tree where all nodes are either 0 or 1, prune the tree so that subtrees containing all 0s are removed.

For example, given the following tree:
```
   0
  / \
 1   0
    / \
   1   0
  / \
 0   0
```
should be pruned to:
```
   0
  / \
 1   0
    /
   1
```
We do not remove the tree at the root or its left child because it still has a 1 as a descendant.

Pull request:
Day146
Resolves #303.

Patch:
diff --git a/README.md b/README.md
index 1eed3fe..bb128c6 100644
--- a/README.md
+++ b/README.md
@@ -154,4 +154,5 @@ problems from
 * [Day 141](https://github.com/vaskoz/dailycodingproblem-go/issues/294)
 * [Day 142](https://github.com/vaskoz/dailycodingproblem-go/issues/297)
 * [Day 143](https://github.com/vaskoz/dailycodingproblem-go/issues/299)
+* [Day 146](https://github.com/vaskoz/dailycodingproblem-go/issues/303)
 * [Day 147](https://github.com/vaskoz/dailycodingproblem-go/issues/304)
diff --git a/day146/problem.go b/day146/problem.go
new file mode 100644
index 0000000..2f4df1f
--- /dev/null
+++ b/day146/problem.go
@@ -0,0 +1,21 @@
+package day146
+
+// BinaryTree contains values of either zero (0) or one (1).
+type BinaryTree struct {
+	Value       int
+	Left, Right *BinaryTree
+}
+
+// PruneZeroSubtrees prunes all the subtrees containing only zeros.
+// NOTE: This mutates the input.
+func PruneZeroSubtrees(head *BinaryTree) *BinaryTree {
+	if head == nil {
+		return nil
+	}
+	head.Left = PruneZeroSubtrees(head.Left)
+	head.Right = PruneZeroSubtrees(head.Right)
+	if head.Value == 0 && head.Left == nil && head.Right == nil {
+		return nil
+	}
+	return head
+}


Test patch:
diff --git a/day146/problem_test.go b/day146/problem_test.go
new file mode 100644
index 0000000..3bfd21a
--- /dev/null
+++ b/day146/problem_test.go
@@ -0,0 +1,73 @@
+package day146
+
+import "testing"
+
+var testcases = []struct {
+	head, expected *BinaryTree
+}{
+	{&BinaryTree{
+		0,
+		&BinaryTree{
+			1,
+			nil,
+			nil,
+		},
+		&BinaryTree{
+			0,
+			&BinaryTree{
+				1,
+				&BinaryTree{
+					0,
+					nil,
+					nil,
+				},
+				&BinaryTree{
+					0,
+					nil,
+					nil,
+				},
+			},
+			&BinaryTree{
+				0,
+				nil,
+				nil,
+			},
+		},
+	},
+		&BinaryTree{
+			0,
+			&BinaryTree{1, nil, nil},
+			&BinaryTree{0,
+				&BinaryTree{1, nil, nil},
+				nil},
+		},
+	},
+}
+
+func TestPruneZeroSubtrees(t *testing.T) {
+	t.Parallel()
+	for tcid, tc := range testcases {
+		if result := PruneZeroSubtrees(tc.head); !treeEqual(result, tc.expected) {
+			t.Errorf("TCID%d didn't match", tcid)
+		}
+	}
+}
+
+func BenchmarkPruneZeroSubtrees(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			PruneZeroSubtrees(tc.head)
+		}
+	}
+}
+
+func treeEqual(one, two *BinaryTree) bool {
+	if one == nil && two == nil {
+		return true
+	} else if one == nil && two != nil {
+		return false
+	} else if one != nil && two == nil {
+		return false
+	}
+	return treeEqual(one.Left, two.Left) && treeEqual(one.Right, two.Right)
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 357
Good morning! Here's your coding interview problem for today.

This problem was asked by LinkedIn.

You are given a binary tree in a peculiar string representation. Each node is written in the form `(lr)`, where `l` corresponds to the left child and `r` corresponds to the right child.

If either `l` or `r` is `null`, it will be represented as a zero. Otherwise, it will be represented by a new `(lr)` pair.

Here are a few examples:

* A root node with no children: `(00)`
* A root node with two children: `((00)(00))`
* An unbalanced tree with three consecutive left children: `((((00)0)0)0)`

Given this representation, determine the depth of the tree.

Pull request:
Day357
Resolves #706.

Patch:
diff --git a/README.md b/README.md
index 19daf0e..6117477 100644
--- a/README.md
+++ b/README.md
@@ -343,6 +343,7 @@ problems from
 * [Day 353](https://github.com/vaskoz/dailycodingproblem-go/issues/701)
 * [Day 355](https://github.com/vaskoz/dailycodingproblem-go/issues/704)
 * [Day 356](https://github.com/vaskoz/dailycodingproblem-go/issues/705)
+* [Day 357](https://github.com/vaskoz/dailycodingproblem-go/issues/706)
 * [Day 359](https://github.com/vaskoz/dailycodingproblem-go/issues/708)
 * [Day 360](https://github.com/vaskoz/dailycodingproblem-go/issues/709)
 * [Day 361](https://github.com/vaskoz/dailycodingproblem-go/issues/712)
diff --git a/day357/problem.go b/day357/problem.go
new file mode 100644
index 0000000..b3157c8
--- /dev/null
+++ b/day357/problem.go
@@ -0,0 +1,24 @@
+package day357
+
+// StringTreeDepth returns the height of the binary tree
+// using the problem stated notation for the tree.
+// Runs in O(N) time where N is the length of the input string
+//  and O(1) space.
+func StringTreeDepth(tree string) int {
+	var maxStreak, current int
+
+	for _, r := range tree {
+		switch r {
+		case '(':
+			current++
+		case ')':
+			current--
+		}
+
+		if current > maxStreak {
+			maxStreak = current
+		}
+	}
+
+	return maxStreak
+}


Test patch:
diff --git a/day357/problem_test.go b/day357/problem_test.go
new file mode 100644
index 0000000..3bd7051
--- /dev/null
+++ b/day357/problem_test.go
@@ -0,0 +1,34 @@
+package day357
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	tree  string
+	depth int
+}{
+	{"(00)", 1},
+	{"((00)(00))", 2},
+	{"((((00)0)0)0)", 4},
+	{"((0((00)0))(00))", 4},
+	{"(0(0(0(0(0(00))))))", 6},
+	{"(((0(((00)(00))((00)(00))))0)(0((((0(00))0)0)(00))))", 7},
+}
+
+func TestStringTreeDepth(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if depth := StringTreeDepth(tc.tree); depth != tc.depth {
+			t.Errorf("For tree %s, expected %v, got %v", tc.tree, tc.depth, depth)
+		}
+	}
+}
+
+func BenchmarkStringTreeDepth(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			StringTreeDepth(tc.tree)
+		}
+	}
+}