Minimum number of operations to convert array A to array B by adding an integer into a subarray.

Revision en1, by gjaiswal108, 2020-09-01 01:36:18

How to solve this problem ?

Given two arrays A[] and B[] of length N, the task is to find the minimum number of operations in which the array A can be converted into array B where each operation consists of adding any integer K into a subarray from L to R.

Source: https://www.geeksforgeeks.org/minimum-number-of-operations-to-convert-array-a-to-array-b-by-adding-an-integer-into-a-subarray/

PS: I came across this problem on gfg, but then realised that their solution is Wrong. It fails on the following case: A = {0, 0, 0}, B = {1, 2, 1} Output should be 2, but their code is giving 3.

Tags #problem solving

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English gjaiswal108 2020-09-01 02:58:47 6
en2 English gjaiswal108 2020-09-01 02:57:34 212
en1 English gjaiswal108 2020-09-01 01:36:18 700 Initial revision (published)