I need to find the SUMMATION of Si * Ci (for i in range of 1 to n).
Following are the constraints:
1 ≤ n ≤ 10^6
1 ≤ si ≤ 10^6
1 ≤ ci ≤ 10^6
Here is my code.
<?php
for($i = 0; $i < $n; $i++){
$total += ($s[$i] * $c[$i]);
}
?>
However, the code runs out of time for high input values(upto 10 ^ 6).
How to add such huge numbers with proper optimisation techniques without exceeding the execution time.