@@ -0,0 +1,2546 @@
+package linked_list;%0A%0Aimport datastructures.lists.CustomLinkedList;%0Aimport datastructures.lists.LinkedListNode;%0A%0Apublic class AddPolynomialsLinkedList %7B%0A%0A  private CustomLinkedList%3CVariable%3E linkedList = null;%0A  private CustomLinkedList%3CVariable%3E linkedList2 = null;%0A%0A  public void constructLinkedList(String input, String input2) %7B%0A    linkedList = new CustomLinkedList%3CVariable%3E();%0A    linkedList2 = new CustomLinkedList%3CVariable%3E();%0A    String%5B%5D elements = input.split(%22%5C%5C+%22);%0A    String%5B%5D elements2 = input2.split(%22%5C%5C+%22);%0A%0A    for (String e : elements) %7B%0A      if (e != null && !e.trim().isEmpty()) %7B%0A        String%5B%5D values = e.trim().split(%22x%5C%5C%5E%22);%0A        linkedList.add(new Variable(Integer.parseInt(values%5B0%5D), Integer.parseInt(values%5B1%5D)));%0A      %7D%0A    %7D%0A%0A    for (String e : elements2) %7B%0A      if (e != null && !e.trim().isEmpty()) %7B%0A        String%5B%5D values = e.trim().split(%22x%5C%5C%5E%22);%0A        linkedList2.add(new Variable(Integer.parseInt(values%5B0%5D), Integer.parseInt(values%5B1%5D)));%0A      %7D%0A    %7D%0A  %7D%0A%0A  public String addPolynomials() %7B%0A    StringBuilder builder = new StringBuilder();%0A    LinkedListNode%3CVariable%3E current = linkedList.head();%0A    LinkedListNode%3CVariable%3E current2 = linkedList2.head();%0A%0A    while (current != null && current2 != null) %7B%0A      if (current.data.power == current2.data.power) %7B%0A        builder.append(current.data.coefficient + current2.data.coefficient).append(%22x%5E%22).append(current.data.power)%0A            .append(%22 + %22);%0A        current = current.next;%0A        current2 = current2.next;%0A      %7D else if (current.data.power %3E current2.data.power) %7B%0A        builder.append(current.data.getVariableString());%0A        current = current.next;%0A      %7D else %7B%0A        builder.append(current2.data.getVariableString());%0A        current2 = current2.next;%0A      %7D%0A    %7D%0A    %0A    while(current != null) %7B%0A      builder.append(current.data.getVariableString());%0A      current = current.next;%0A    %7D%0A    %0A    while(current2 != null) %7B%0A      builder.append(current2.data.getVariableString());%0A      current2 = current2.next;%0A    %7D%0A%0A    return builder.toString().substring(0, builder.length() - 3);%0A  %7D%0A%0A  class Variable %7B%0A    private int coefficient = 0;%0A    private int power = 0;%0A%0A    public Variable(int coefficent, int power) %7B%0A      this.coefficient = coefficent;%0A      this.power = power;%0A    %7D%0A    %0A    public String getVariableString() %7B%0A      StringBuilder builder = new StringBuilder();%0A      builder.append(coefficient).append(%22x%5E%22).append(power).append(%22 + %22);%0A      return builder.toString();%0A    %7D%0A  %7D%0A%7D%0A

Add solution for AddPolynomialsLinkedList