Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 157
Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Given a string, determine whether any permutation of it is a palindrome.

For example, `carrace` should return `true`, since it can be rearranged to form racecar, which is a palindrome. `daily` should return `false`, since there's no rearrangement that can form a palindrome.

Pull request description:
Day157
Resolves #327.

Patch:
diff --git a/README.md b/README.md
index b544125..3cbba53 100644
--- a/README.md
+++ b/README.md
@@ -167,3 +167,4 @@ problems from
 * [Day 154](https://github.com/vaskoz/dailycodingproblem-go/issues/320)
 * [Day 155](https://github.com/vaskoz/dailycodingproblem-go/issues/322)
 * [Day 156](https://github.com/vaskoz/dailycodingproblem-go/issues/325)
+* [Day 157](https://github.com/vaskoz/dailycodingproblem-go/issues/327)
diff --git a/day157/problem.go b/day157/problem.go
new file mode 100644
index 0000000..0112fe1
--- /dev/null
+++ b/day157/problem.go
@@ -0,0 +1,18 @@
+package day157
+
+// IsPermutationPalindrome answers if the given string
+// can be permutated into a palindrome.
+// Runs in O(N) time and O(N) space.
+func IsPermutationPalindrome(s string) bool {
+	runeCount := make(map[rune]int)
+	for _, r := range s {
+		runeCount[r]++
+	}
+	var odds int
+	for _, v := range runeCount {
+		if v%2 == 1 {
+			odds++
+		}
+	}
+	return odds < 2
+}


Test patch:
diff --git a/day157/problem_test.go b/day157/problem_test.go
new file mode 100644
index 0000000..8671221
--- /dev/null
+++ b/day157/problem_test.go
@@ -0,0 +1,28 @@
+package day157
+
+import "testing"
+
+var testcases = []struct {
+	s        string
+	expected bool
+}{
+	{"carrace", true},
+	{"daily", false},
+}
+
+func TestIsPermutationPalindrome(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := IsPermutationPalindrome(tc.s); result != tc.expected {
+			t.Errorf("For %v got %v got %v", tc.s, result, tc.expected)
+		}
+	}
+}
+
+func BenchmarkIsPermutationPalindrome(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			IsPermutationPalindrome(tc.s)
+		}
+	}
+}