Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5646 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4716 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@skj7 | 671 |

@gurshehzadsingh | 418 |

@swastik8750 | 411 |

@nishunishuraj18 | 405 |

@vedantvalsangkar | 390 |

@deepakchowdary | 380 |

@akashverma4 | 369 |

@satyamannsm | 353 |

@2018uec1603 | 333 |

@rkrupeshkumar345 | 331 |

@surajmamgai | 330 |

Complete Leaderboard |

Given an array **A** of size **N**, construct a Sum Array **S**(of same size) such that** **S is equal to the sum of all the elements of **A** except A[i]. Your task is to complete the function **SumArray(A, N)** which accepts the array A and N(size of array).

**Example 1:**

Input:5 3 6 4 8 9Output:27 24 26 22 21Explanation:For the sum array S, at i=0 we have 6+4+8+9. At i=1, 3+4+8+9. At i=2, we have 3+6+8+9. At i=3, we have 3+6+4+9. At i = 4, we have 3+6+4+8. So S is 27 24 26 22 21.

**Example 2:**

Input:6 4 5 7 3 10 1Output:26 25 23 27 20 29

**User Task:**

Since this is a functional problem you did not have to worry about the input and output. You just have to complete the function **SumArray() **by storing arr[i]=S-arr[i]

**Constraint :**

1 <= T <= 10

1 <= N <= 10^{4}

1 <= A_{i} <= 10^{4}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Sum Array Puzzle

...