Sherlock and Cost Discussions | Algorithms | HackerRank
  • + 1 comment

    abs(ar[i]-1) is not added to dp[i][0] because dp[i][0] means we are taking ar[i]=1 and dp[i+1][0] means we are taking ar[i+1] as 1 now abs(ar[i]-1) will be abs(1-1) which is 0.so there is no need to add someting which is always going to be zero

    • + 0 comments

      thank for your explaning.