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

Правка en2, от gjaiswal108, 2020-09-01 02:57:34

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.

Edit: there can be two variation of this problem: 1st — When K is a positive integer 2nd — When K can be any integer There might be different solution for both. So answer by assuming each case.

Теги #problem solving

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский gjaiswal108 2020-09-01 02:58:47 6
en2 Английский gjaiswal108 2020-09-01 02:57:34 212
en1 Английский gjaiswal108 2020-09-01 01:36:18 700 Initial revision (published)