Hi I have the following integral:
$$\int \frac{2x}{x^2+6x+3}\, dx$$

I made some changes like:
$$\int \dfrac{2x+6-6}{x^2+6x+3}\, dx$$

then I have: 
$$\int \dfrac{2x+6}{x^2+6x+3}\, dx -\int\dfrac{6}{x^2+6x+3}\, dx$$

and thus: $$\ln(x^2+6x+3)-\int\dfrac{6}{x^2+6x+3}\, dx$$

Ok, I have decomposed $$\frac{2x}{x^2+6x+3} $$  in: $$ \frac{3+\sqrt6}{\sqrt6(x+\sqrt 6+3)} + \frac{3-\sqrt6}{\sqrt6 (-x+\sqrt6-3)}$$

How can I integrate this expressions?


Question: Two sets came to an intersection
Answer: This is a fine implementation. 
It's well-formatted and nicely written.
I find the idea of using a LinkedHashSet quite clever and interesting.
There are a couple of points to improve though.

You have a bug

Do you notice something fishy here?


while (foo[i] &gt; bar[j] &amp;&amp; j &lt; bar.length) {
    j++;
}
if (foo[i] &lt; bar[j]) {



The condition in the while checks foo[i] &gt; bar[j] before j &lt; bar.length.
So when j reaches bar.length,
this will throw an ArrayIndexOutOfBoundsException.

Flipping the &amp;&amp; may seem like an obvious remedy.
But it won't be enough,
because of the next if statement after the while loop,
you'll again have the problem if j has already reached bar.length.

An example input to demonstrate this issue: 33;3,4

Unit testing

It's always handy to have some unit tests around when solving challenges like this.
For example:

@Test
public void test_9_10_11_x_33_34_35() {
    assertEquals("", findIntersection("9,10,11;33,34,35"));
}

@Test
public void test_3_7_8_22_x_11_22() {
    assertEquals("22", findIntersection("3,7,8,22;11,22"));
}

@Test
public void test_11_12_13_14_x_14_15_16() {
    assertEquals("14", findIntersection("11,12,13,14;14,15,16"));
}

@Test
public void test_20_21_22_x_45_46_47() {
    assertEquals("", findIntersection("20,21,22;45,46,47"));
}

@Test
public void test_77_78_79_x_78_79_80_81_82() {
    assertEquals("78,79", findIntersection("77,78,79;78,79,80,81,82"));
}

@Test
public void test_33_35_x_3_18_26_35() {
    assertEquals("35", findIntersection("33,35;3,18,26,35"));
}

@Test
public void test_33_x_3_4() {
    assertEquals("", findIntersection("33;3,4"));
}


An alternative implementation

Consider this alternative implementation that passes all the tests:

private String findIntersection(String input) {
    String[] parts = input.split(";");
    String[] arr1 = parts[0].split(",");
    String[] arr2 = parts[1].split(",");
    return findIntersection(arr1, arr2);
}

private String findIntersection(String[] arr1, String[] arr2) {
    StringBuilder builder = new StringBuilder();
    for (int pos1 = 0, pos2 = 0; pos1 &lt; arr1.length &amp;&amp; pos2 &lt; arr2.length; ) {
        int value1 = Integer.parseInt(arr1[pos1]);
        int value2 = Integer.parseInt(arr2[pos2]);

        if (value1 == value2) {
            builder.append(value1).append(",");
            ++pos1;
            ++pos2;
        } else if (value1 &lt; value2) {
            ++pos1;
        } else {
            ++pos2;
        }
    }
    if (builder.length() == 0) {
        return "";
    }
    return builder.substring(0, builder.length() - 1);
}


This implementation has an advantage and disadvantage compared to yours:


Advantages:


It doesn't always convert all input values to integers. For example when you have a long list and a short list, and it turns out that they cannot have an intersection, the rest of the long list will not be converted to integers
It should be faster to generate the output from a StringBuilder than from a LinkedHashSet

Disadvantage: in common cases it converts input values to numbers twice.
This is because in every step of the while loop, when only one of the positions advance, then on the next step the other number will be converted to integer again.


There is possibly one more advantage:
it's not clear if in the output the values should be separated by single commas,
or by comma + space as in yours (and in the output of Set.toString).
Since the values are separated by , in the input,
I would assume the same rule for the output as well,
but I could be wrong.
But if I'm right,
then to get the right output you would have to strip the spaces from the result of the Set.toString call.