< Back to forum

Make the Sum Even (March Lunchtime)


Do I need to replace every i th element in the array with pow(A,p) and check for sum to be even? Is there any other method?

Asked by: harshitanand97 on March 27, 2021, 6:13 p.m. Last updated on March 27, 2021, 6:13 p.m.

Enter your answer details below:


Enter your comment details below:


1 Answer(s)


It is written that chef can choose an index i and replace A[i] with A[i]^p. And he has to perform the minimum number of such operations. So it's not necessary for him to perform an operation on each element.

Think it this way, that if he was to replace every element in the array like this, then the number of operations will always be n. Which is definitely contradicting to the sample test cases provided.

mahawarvishal10 last updated on March 31, 2021, 11:35 a.m. 0    Reply    Upvote   

Instruction to write good question
  1. 1. Write a title that summarizes the specific problem
  2. 2. Pretend you're talking to a busy colleague
  3. 3. Spelling, grammar and punctuation are important!

Bad: C# Math Confusion
Good: Why does using float instead of int give me different results when all of my inputs are integers?
Bad: [php] session doubt
Good: How can I redirect users to different pages based on session data in PHP?
Bad: android if else problems
Good: Why does str == "value" evaluate to false when str is set to "value"?

Refer to Stack Overflow guide on asking a good question.