Maximum product subarray

Question;-https://practice.geeksforgeeks.org/problems/maximum-product-subarray3604/1#

code:-

Here’s my function declaration for the given code. Can you tell me where am I going wrong?

hello @div_yanshu07
logic is not correct. here exact kadane will not work.

try to maintain largest running negative number and largest running positive number and then apply kadane over those two numbers to get maximum.
why to keep track of running negative ?
becuase it may happend that running negative * current (also negative ) can give u largest number.

for more details refer this ->link

Now, I think the implementation is correct but the problem is with max function it is not comparing with long long int and int


How to correct?

use long long for all variables or explicitly typecast int to long long

I am getting this now for given function declaration

https://ide.codingblocks.com/s/366781

Wrong Answer. !!!Wrong Answer

Possibly your code doesn’t work correctly for multiple test-cases (TCs).

The first test case where your code failed:

Input:
10 90 91 -91 91 -91 -90 90 90 -90 -90

Its Correct output is:
404928287208900000

And Your Code’s output is:
449942298618103232

ur implementation is correct .

once check their implementation , try to submit it and see it is working or not.