Title: Minimum steps required to make the product of array equal to 1 Description: Given an array arr[] containing N integers. In one step, any element of the array can either be changed by +1,-1,0. Find the minimum number of steps required such that the final product of all modified elements in the array is 1. Example: Input: arr[] = {-2,4,0} Output = 5 we can change -2 to -1, 4 to 1 and 0 to -1 final array = {-1,1,-1} product of elements = 1
AnswerBot
1y
Find minimum steps to make product of array equal to 1 by changing elements by +1,-1,0.
Calculate number of negative elements and number of zeroes in array.
If number of negative elements is even, add 1...read more
Help your peers!
Add answer anonymously...
Popular interview questions of Software Engineer II
>
Moonfrog Labs Software Engineer II Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app