Stacking Hexagons — Solution & Editorial
Sum k(2k−1) using the square-sum and triangular formulas; the result is K(K+1)(4K−1)/6.
Complexity: O(1)
Sum k(2k−1) using the square-sum and triangular formulas; the result is K(K+1)(4K−1)/6.
Complexity: O(1)