D E Shaw interview Experience (geeksforgeeks)
Difference between en1 and en2, changed 2 character(s)
Given 2 arrays, array A (containing only 0s and 1s) and the other cost array B of the same size. We needed to convert all the elements of array A to 1 in minimum cost. For every ith element in the array A, converting from 0 to 1 requires B[i] cost but if A[i-1] and A[i+1] are 1 then A[i] can be converted to 1 with 0 cost. Return the minimum possible cost to convert all 0s to 1s. ↵
My approach-↵
Isn't this simply 
$dp[i]=min(dp[i-1],dp[i-2])+cost[i]$;↵

Can someone please confirm?↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English just_for_one 2021-08-03 10:48:42 2 (published)
en1 English just_for_one 2021-08-03 10:47:03 529 Initial revision (saved to drafts)