The row-wise sum of the transpose is just the column-wise sum of the original matrix. So, for inputs $a_1 \cdots a_n$ and outputs $b_1 \cdots b_m$, it looks something like this:
$$
\begin{array}{c|c&c&c&lcr}
& b_1=4 & b_2=2 & b_3=1 \\
\hline
a_1=3 & 1 & 1 & 1 \\
a_2=2 & 1 & 1 & 0 \\
a_3=1 & 1 & 0 & 0 \\
a_4=1 & 1 & 0 & 0
\end{array}
$$
Each output is equal to the number of rows long enough to reach it. Therefore, a value $a_k$ affects the first $a_k$ outputs.
Algorithm description
First, initialize a vector of length $m$ called $b$, setting all elements to $0$. Next, for each element $a_i$ in $a$, increment $b_{a_i}$ by one. (this is the last element to be affected by $a_i$.)
Next, we will iterate backward over $b$, adding the next element and storing the result back into $b$. This effectively sums all higher elements in the old $b$.
Pseudocode:
conjugate(array a, int n, int m)
b = new Array length m (all zeros)
for i = 1 to n
b[a[i]] += 1
for i = m-1 downto 1
b[i] += b[i+1]
return b
Ruby Implementation
def conjugate(a)
b = Array.new(a[0], 0)
a.each do |x|
b[x-1] += 1
end
(a[0]-2).downto 0 do |i|
b[i] += b[i+1]
end
b
end
Try it online!
Efficiency
We have one loop over $a$ and one loop over $b$, giving $\Theta(n+m)$.