Given an array A of size N. Find the minimum number of operations needed to convert the given array to Palindromic Array
belongs to collection: Interview C++ coding problems/challenges | arrays
All Answers
total answers (1)
belongs to collection: Interview C++ coding problems/challenges | arrays
total answers (1)
Algorithm:
For solving the above problem a recursive algorithm can be constructed based on the following conditions.
Let array [i, j] be the subarray to be checked where I be the staring index & j be the end index
So there can be three cases,
Based on these three conditions we have constructed the recursive function:
Example with explanation:
C++ implementation:
Output