Help in memoization

I have figured out the recursive solution to this problem. I now need help in optimizing it with memoization. Please help

Recusrive solution: https://ide.codingblocks.com/s/482917

Please Reply :slight_smile:

why you are using recursion or dp here??
this is simple question
make different cases based on no of pairs having odd-odd odd-even even-even