Level EASY
Given an array, update each element of the array by the value obtained by dividing the element by 4 (take only integer part). If the value obtained by dividing the element by 4 comes out to be 0, then update the element with value -1.
Note: Do not return or print the array and make changes in the same array.
Line 1: An Integer N i.e. size of the array
Line 2: N integers which are elements of the array, separated by spaces
N elements of the array, separated by space
Constraints :
1 <= N <= 10^5
0 <= array[i] <= 100
Time Limit: 1 sec
Sample Input :
2
3 8
Sample Output :
-1 2
Sample Output Explanation :
The input list is [ 3, 8 ] , after dividing each element by 4, our list becomes [ 0, 2 ] . So as the first element is 0 so replace it by -1.
Comments
Post a Comment
Please give us your valuable feedback