Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

ARRPROB – Editorial

$
0
0

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.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>