Please subscribe to the official Codeforces channel in Telegram via the link ×

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

Revision en3, by gjaiswal108, 2020-09-01 02:58:47

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.


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.

Tags #problem solving


  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)