Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 80
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

Given the root of a binary tree, return a deepest node. For example, in the following tree, return d.
```
    a
   / \
  b   c
 /
d
```

Pull request:
Day80
Resolves #168. 

Patch:
diff --git a/README.md b/README.md
index 8f963b9..41acb17 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ problems from
 * [Day 10](https://github.com/vaskoz/dailycodingproblem-go/issues/21)
 * [Day 11](https://github.com/vaskoz/dailycodingproblem-go/issues/23)
 * [Day 12](https://github.com/vaskoz/dailycodingproblem-go/issues/25)
-* [Day 12 Count and Deepest](https://github.com/vaskoz/dailycodingproblem-go/issues/27)
+* [Day 12 Count](https://github.com/vaskoz/dailycodingproblem-go/issues/27)
 * [Day 13](https://github.com/vaskoz/dailycodingproblem-go/issues/29)
 * [Day 14](https://github.com/vaskoz/dailycodingproblem-go/issues/31)
 * [Day 15](https://github.com/vaskoz/dailycodingproblem-go/issues/33)
@@ -89,3 +89,4 @@ problems from
 * [Day 77](https://github.com/vaskoz/dailycodingproblem-go/issues/163)
 * [Day 78](https://github.com/vaskoz/dailycodingproblem-go/issues/165)
 * [Day 79](https://github.com/vaskoz/dailycodingproblem-go/issues/167)
+* [Day 80](https://github.com/vaskoz/dailycodingproblem-go/issues/168)
diff --git a/countBinaryTreeNodes/problem.go b/countBinaryTreeNodes/problem.go
new file mode 100644
index 0000000..e156200
--- /dev/null
+++ b/countBinaryTreeNodes/problem.go
@@ -0,0 +1,15 @@
+package deepest
+
+// BinaryTree represents a tree with a left and right subtree.
+type BinaryTree struct {
+	// val         int // value doesn't matter here.
+	left, right *BinaryTree
+}
+
+// CountNodes tallies the total number of nodes in the binary tree.
+func CountNodes(root *BinaryTree) int {
+	if root == nil {
+		return 0
+	}
+	return CountNodes(root.left) + CountNodes(root.right) + 1
+}
diff --git a/deepestBinaryTree/problem.go b/day80/problem.go
similarity index 75%
rename from deepestBinaryTree/problem.go
rename to day80/problem.go
index b571d24..dc1b6c7 100644
--- a/deepestBinaryTree/problem.go
+++ b/day80/problem.go
@@ -1,4 +1,4 @@
-package deepest
+package day80
 
 // BinaryTree represents a tree with a left and right subtree.
 type BinaryTree struct {
@@ -6,14 +6,6 @@ type BinaryTree struct {
 	left, right *BinaryTree
 }
 
-// CountNodes tallies the total number of nodes in the binary tree.
-func CountNodes(root *BinaryTree) int {
-	if root == nil {
-		return 0
-	}
-	return CountNodes(root.left) + CountNodes(root.right) + 1
-}
-
 // Deepest returns the deepest node in the binary tree.
 func Deepest(root *BinaryTree) (*BinaryTree, int) {
 	if root != nil && root.left == nil && root.right == nil {


Test patch:
diff --git a/deepestBinaryTree/problem_test.go b/countBinaryTreeNodes/problem_test.go
similarity index 64%
rename from deepestBinaryTree/problem_test.go
rename to countBinaryTreeNodes/problem_test.go
index da65eba..b172ffb 100644
--- a/deepestBinaryTree/problem_test.go
+++ b/countBinaryTreeNodes/problem_test.go
@@ -24,19 +24,3 @@ func BenchmarkCountNodes(b *testing.B) {
 		CountNodes(root)
 	}
 }
-
-func TestDeepest(t *testing.T) {
-	t.Parallel()
-	root := buildTestTree()
-	if _, count := Deepest(root); count != 4 {
-		t.Errorf("Expected 4 but got %v", count)
-	}
-}
-
-func BenchmarkDeepest(b *testing.B) {
-	root := buildTestTree()
-	b.ResetTimer()
-	for i := 0; i < b.N; i++ {
-		Deepest(root)
-	}
-}
diff --git a/day80/problem_test.go b/day80/problem_test.go
new file mode 100644
index 0000000..a6a69a1
--- /dev/null
+++ b/day80/problem_test.go
@@ -0,0 +1,26 @@
+package day80
+
+import "testing"
+
+// nodes = 5 depth = 3
+func buildTestTree() *BinaryTree {
+	return &BinaryTree{&BinaryTree{&BinaryTree{nil, nil},
+		&BinaryTree{&BinaryTree{nil, nil}, nil}},
+		&BinaryTree{nil, &BinaryTree{nil, nil}}}
+}
+
+func TestDeepest(t *testing.T) {
+	t.Parallel()
+	root := buildTestTree()
+	if _, count := Deepest(root); count != 4 {
+		t.Errorf("Expected 4 but got %v", count)
+	}
+}
+
+func BenchmarkDeepest(b *testing.B) {
+	root := buildTestTree()
+	b.ResetTimer()
+	for i := 0; i < b.N; i++ {
+		Deepest(root)
+	}
+}