Big-O complexity calculation for a merge and sort function
If N == number of input arrays and M == length of the longest input array then your outer while loop will run M times with the check condition being O(N) so your outer loop is O(MN). The inner loop runsNtimes and the heap insert isO(log(N))so your inner body isO(Nlog(N)). Resulting in a total complexity of O(M * N^2 * log(N))

Some review:

I find the entire code very confusing and hard to read. You keep track of different properties for the same array in disjoint helper arrays (indices and endOfArray) while they should be combined in a single state object.

Also your input is Object[] while obviously you expect a list of int[] so why not express that in your parameter directly like: List&lt;int[]&gt; input.

Your result is a non-generic ArrayList so it's really hard to know what the exact return type of the elements is. Reading through the code it looks like the elements get returned as strings which is probably very confusing for the user - why on earth would a method to which I pass a list of integer arrays return the merged result as an array of strings?

If I read your intention correctly then you want to merge the input arrays, remove all duplicates and return the result ordered. You can write that very nicely with LINQ:

public List&lt;int&gt; MergeLists(List&lt;int[]&gt; lists)
{
    return lists.SelectMany(l =&gt; l) // flatten into single collection
                .Distinct()         // remove duplicates
                .OrderBy(x =&gt; x)    // sort the result
                .ToList();          // build result list
}


Assuming all N arrays have the same maximum length M then the complexity should be:


Distinct() is in the order of O(N * M)
OrderBy() is in the order of O(N * M * log(N * M))
ToList() is in the order of O(N * M)


Which means the resulting complexity is O(N * M * log(N * M) so you have cut it down to linear in terms of number of input arrays and the code is significantly shorter, easier to read and maintain and very likely to contains fewer bugs.