Flood fill not getting full marks


why is one of the test case is not passing ?? what am i missing in my approach??

hello @Shobhit_kumar
the second case is giving mle.
try this.
remove consecutive repeated elements from ur array then apply ur logic.

for example->
if array is 1 1 2 2 3 then transform it to 1 2 3

I have already done this sir and after that i am applying the logic… please help

pls wait i m working on ur code only.

https://ide.codingblocks.com/s/350643 this is my code

sir do find anything??

yeah , in line 15 u r using char , replace it with int and then it will work fine (on codeforces)

sir i have replaced char with int still it is not giving me 100 marks please tell the reason for coding blocks submission

see ur code is correct, in cb ur code is not passing probably becuase it has very strict memory contraints.
i tried submitting ur code on cf and it worked there( accepted)

so please tell me the optimized approach of this problem so that i can learn something new from this problme. i want to submit this correctly here and get 100 marks . please tell the optimized approach

there is no other approach for this problem.urs is optimised one only

wait let me send u editorial code

do one thing instead of using a function , put everthing in main function and declare all arrays as global and then try to submit

yes sir please send the editorial code… i want to see what is different in it…

first try what i suggested if it fails then ping me back

https://ide.codingblocks.com/s/350643 here is the updated code still it is not getting wa

sorry still it is not getting AC

@Shobhit_kumar
check now (made ur dp array global) ->

sir now it got AC … so what does that mean do vectors take more time than array and is making them global reduces time complexity?? if yes how ?? and do they have anything to do with space complexity also??

in global scope we can allocate larger memory compared to function scope thats why ur code is not working when u r declaring ur array inside function but same code working on global declaration of array