Find whether there can be exactly N - 1 elements with value zero
Anonymous User
213

Given an array of N non negative integers and an integer K, return true or false based on if there can be exactly N - 1 elements with value as 0 by performing following action infinite times:

  1. You may select any index i and subtract 1 from it.
  2. You cannot select the index where arr[i] == 0, i.e. the number at any given index cannot be negative
  3. To all the remaining N - 1 elements, K will be added

For e.g. arr[] = [1,2,3,4,5], K = 2

If you select index 0, then array becomes [0, 4, 5, 6, 7]

Comments (1)