Problem Statement -
this Problem Positive prefix taken from CodeChef December long challenge.Let's read Problem statement.
1 3 3
1 2 3
Hint- learn Prefix array to solve this question.
This question is totally observation-based.You should good observer to solve this problem.
Solution since there can be multiple solution of this problem one of them is to print alternate +i and -i.
in my case what i am doing
I have created an output array in which i am storing +i and -i alternatively.
then I iterate over the array and I calculate the prefix array.
Then I calculated total positive and negative number store in the output array.And i build the following logic
Here is my entire code.
Join Telegram Channel for solution.