Time complexity of a triple nested for loop for ThreeSum problem
The second loop runs only on $j &gt; i$. Only (roughly) half of the pairs $(i,j)$ between $0$ and $N-1$ satisfy $j &gt; i$. Similarly, the third loop runs only on $k &gt; j &gt; i$, and only (roughly) $1/3!$ of the triples $(i,j,k)$ satisfy that condition.

If you want to be more accurate, $B$ runs this many times
$$ \sum_{i=0}^{N-1} (N-i-1) = \sum_{i=0}^{N-1} i = \frac{i(i-1)}{2}. $$
I'll leave you the calculation for $C$.