I like your code.
It's simple and doesn't need comments because the code is the documentation.
Found it easy to read and understand.
shikhs.prasad
@shikhs.prasad
Posts made by shikhs.prasad

RE: Java 15ms Solution with Two auxiliary array. O(N) time.

RE: O(mn) Java, 2ms
I like the way you directly calculated the distance from the I and J arrays in the second solution.
I did something similar, but then found out the meeting points and then computed the distance.
For the test cases on the OJ though that runs in 2 ms as well.
If someone's curious as to how I found those points, I did it by maintaining the lSum and rSum for each index. Then with help of some maths concluded that the min point would the the one where I[i] >= Math.abs(lSum[i]rSum[i]). And that such an i, always exists for any one dimensional array. 
RE: Am I the only person who don't know why median could give shortest distance?
The article you point to is nice, but that is minimizing sx, whereas in the question we need to minimize sx*s, which doesn't necessarily have to be the median.

RE: Java UnionFind Beats 96%
The test cases for this question are very weak.
This particular implementation doesn't work, but I think the idea is fine. The case when this fails is when eq1 and eq2 belong to different sets.
Try the following test case:
[ ["a","c"],["a","b"],["d","e"],["a","d"] ]
[12.0,3.0,3.0,2.0]
[ ["b","d"],["c","d"],["a","e"],["c","e"],["x","x"] ]