ARRPROB – Editorial

PROBLEM LINK:

Practice
Contest

Author: Md Shahid
Editorialist: Arkapravo Ghosh

DIFFICULTY:

SIMPLE

PREREQUISITES:

Array

PROBLEM:

An array on N elements is given. We need to print an array of N elements where the element in the i^th index of the new array is the sum of all elements in the given array except the element at index i.

EXPLANATION:

We just need to find the sum of all elements in the array first. Then for each index i of the given array we need to print the (sum – i^th element) of the given array.
The time complexity of this approach is O(n).

AUTHOR’S AND EDITORIALIST’S SOLUTIONS:

Author’s solution can be found here.
Editorialist’s solution can be found here.

2 Likes