Maximum Sum Path in Two Arrays

Hello, Could you please point issue in my code i tried it with some examples it is giving correct result besides it’s not optimised
my code : https://ide.codingblocks.com/s/671736

hi @akshatjain4545 refer this article it has very nicely explained with pictures

Thanks @talhashamim001 I read it but i want my approach to work if its ok

@akshatjain4545 try this:
12 12
1 2 3 5 6 7 8 9 10 14 20 21
1 2 3 4 6 10 11 12 13 14 15 16
ans is 142

ok but my code is giving 132 I try to find issue

Ok I figured with a doubt can we go like that ??

array1(1 2 3 5 6 7 8 9 10)=>array2(10 11 12 13 14)=>array1(14 20 21)

I feel we can switch array single time only

@akshatjain4545 u can switch any no of times…

ok @talhashamim001 thats the issue in my approach thanks

@akshatjain4545 yup…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.