Question: Given an array of N distinct non-zero integers and an integer k, 0 < k N, you have to flip the sign of k numbers
Given an array of N distinct non-zero integers and an integer k, 0 < k N, you have to flip the sign of k numbers in the array such that the resultant array has the maximum possible sum. You may flip a number at most once. Design an O(N) time algorithm for selecting the numbers to flip.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
