11

Find minimum number of merge operations to make an array palindrome

 2 years ago
source link: https://www.geeksforgeeks.org/videos/find-minimum-number-of-merge-operations-to-make-an-array-palindrome/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Find minimum number of merge operations to make an array palindrome

Find minimum number of merge operations to make an array palindrome
Hello everyone and welcome to week. So Geeks
  • 25/05/2022

Given an array of positive integers. We need to make the given array a ‘Palindrome’. The only allowed operation is”merging” (of two adjacent elements). Merging two adjacent elements means replacing them with their sum. The task is to find the minimum number of merge operations required to make the given array a ‘Palindrome’.

To make any array a palindrome, we can simply apply merge operation n-1 times where n is the size of the array (because a single-element array is always palindromic, similar to single-character string). In that case, the size of array will be reduced to 1. But in this problem, we are asked to do it in the minimum number of operations.

Example :

Input : arr[] = {15, 4, 15} Output : 0

Find minimum number of merge operations to make an array palindrome: https://www.geeksforgeeks.org/find-minimum-number-of-merge-operations-to-make-an-array-palindrome/


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK