about summary refs log tree commit diff
path: root/users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py')
-rw-r--r--users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py b/users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py
new file mode 100644
index 000000000000..ced3b336e0d9
--- /dev/null
+++ b/users/wpcarro/scratch/facebook/interview-cake/permutation-palindrome.py
@@ -0,0 +1,8 @@
+from collections import Counter
+
+def permutation_can_be_palindrome(x):
+    odd = 0
+    for _, n in Counter(x):
+        if n % 0 != 0:
+            odd += 1
+    return odd <= 1