Блог пользователя Rishi_Kant

Автор Rishi_Kant, история, 4 года назад, По-английски

Please help me in B. Here is my solution 88615363. My approach

  1. I create two variables c and d to count number of 1 and -1 in list a from index[0,n-1]. I didn't take the last index as it can't be i, it only can be j as i < j.

  2. I check if a[0] is equal to b[0]. if not just print NO.

  3. Now go in else block. I used a loop from last index to 1. Now check if a[i] == b[i] then just check if a[i-1] is 1 then remove count of c by 1 and if a[i-1] is -1 then remove count of d by 1.

  4. Else if a[i] < b[i] then check count of c. If it is greater then 0 remove count by 1 else break and if a[i] > b[i] Just check then check count of d. Please tell me where I did wrong. Thanku

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится