The code is completely correct but then also test case 2 is wrong.
Please help
TEST CASE 2 wrong
Hello @Prakhar_Nagpal,
There are two mistakes in your code:
-
How are you so sure that there won’t be more than 100 elements?
Solution:
int arr[n]; -
Your code will fail for the case when all the elements will be negative.
Reason:
You have initialized the max variable to 0.
Solution:
max=INT8_MIN;
This will initialize it with the minimum value of int.
Hope, this would help.
Give a like if you are satisfied.