diff --git a/pom.xml b/pom.xml
index 10f4609..30891ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,8 +12,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.8
- 1.8
+ 11
+ 11
@@ -39,7 +39,8 @@
org.projectlombok
lombok
- 1.16.8
+ 1.18.12
+ provided
@@ -81,7 +82,7 @@
junit
junit
- 4.12
+ 4.13.1
@@ -133,6 +134,16 @@
2.1
test
+
+ org.apache.beam
+ beam-sdks-java-harness
+ 2.22.0
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.12.3
+
diff --git a/src/main/java/com/eprogrammerz/examples/algorithm/general/Anadrome.java b/src/main/java/com/eprogrammerz/examples/algorithm/general/Anadrome.java
new file mode 100644
index 0000000..a153640
--- /dev/null
+++ b/src/main/java/com/eprogrammerz/examples/algorithm/general/Anadrome.java
@@ -0,0 +1,34 @@
+package com.eprogrammerz.examples.algorithm.general;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Return number of character to be added to make a given string 'word' a anagram of palindrome.
+ */
+public class Anadrome {
+ public int changeToAnadrome(String word) {
+ int[] map = new int[128];
+ int n = word.length();
+ for (int i = 0; i < n; i++) {
+ map[word.charAt(i)]++;
+ }
+
+ int odds = 0;
+
+ for (int count: map) {
+ if (count % 2 != 0) odds++;
+ }
+
+ if (odds == 0) return 0;
+ return odds - 1;
+ }
+
+ @Test
+ public void test() {
+ assertEquals(1, changeToAnadrome("abcb"));
+ assertEquals(2, changeToAnadrome("abc"));
+ assertEquals(0, changeToAnadrome("tatoo"));
+ }
+}
diff --git a/src/main/java/com/eprogrammerz/examples/algorithm/leetcode/Multiplication.java b/src/main/java/com/eprogrammerz/examples/algorithm/leetcode/Multiplication.java
new file mode 100644
index 0000000..2d17fbd
--- /dev/null
+++ b/src/main/java/com/eprogrammerz/examples/algorithm/leetcode/Multiplication.java
@@ -0,0 +1,25 @@
+package com.eprogrammerz.examples.algorithm.leetcode;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+// Return 1 if multiplication is +ve, -1 if negative and 0 if 0
+public class Multiplication {
+ public int solution(int[] A) {
+ int neg = 0;
+ for (int a : A) {
+ if (a < 0) neg++;
+ if (a == 0) return 0;
+ }
+
+ return neg % 2 == 0 ? 1 : -1;
+ }
+
+ @Test
+ public void test() {
+ assertEquals(1, solution(new int[]{-1,2,3,-1}));
+ assertEquals(-1, solution(new int[]{-1,2,3,-1,-2}));
+ assertEquals(0, solution(new int[]{-1,2,3,-1,-2,0}));
+ }
+}
diff --git a/src/main/java/com/eprogrammerz/examples/algorithm/trees/PopulateNextRight.java b/src/main/java/com/eprogrammerz/examples/algorithm/trees/PopulateNextRight.java
new file mode 100644
index 0000000..3718273
--- /dev/null
+++ b/src/main/java/com/eprogrammerz/examples/algorithm/trees/PopulateNextRight.java
@@ -0,0 +1,82 @@
+package com.eprogrammerz.examples.algorithm.trees;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * You are given a perfect binary tree where all leaves are on the same level,
+ * and every parent has two children. The binary tree has the following definition:
+ * struct Node {
+ * int val;
+ * Node *left;
+ * Node *right;
+ * Node *next;
+ * }
+ *
+ * https://leetcode.com/problems/populating-next-right-pointers-in-each-node/
+ */
+public class PopulateNextRight {
+ public Node connect(Node root) {
+ Node curr = root;
+
+ while (curr != null && curr.left != null) {
+ Node runner = curr.left;
+ Node temp = runner;
+ Node prev = null;
+
+ while (curr != null) {
+ runner = curr.left;
+ if (prev != null) {
+ prev.next = runner;
+ }
+
+ runner.next = curr.right;
+ runner = runner.next;
+ prev = runner;
+ curr = curr.next;
+ }
+
+ curr = temp;
+ }
+
+ return root;
+ }
+
+ @Test
+ public void test() {
+ Node root = new Node(1);
+ root.left = new Node(2);
+ root.right = new Node(3);
+ root.left.left = new Node(4);
+ root.left.right = new Node(5);
+ root.right.left = new Node(6);
+ root.right.right = new Node(7);
+
+ Node populated = connect(root);
+
+ assertEquals(3, populated.left.next.val);
+ assertEquals(6, populated.left.right.next.val);
+ }
+
+ static class Node {
+ public int val;
+ public Node left;
+ public Node right;
+ public Node next;
+
+ public Node() {}
+
+ public Node(int _val) {
+ val = _val;
+ }
+
+ public Node(int _val, Node _left, Node _right, Node _next) {
+ val = _val;
+ left = _left;
+ right = _right;
+ next = _next;
+ }
+ }
+}