Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given an array/list, 'arr’ of size ‘N’ 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 element by 4 comes out to be 0, then update the element with value -1.

```
Do not return or print the array and make changes in the same array.
```

```
Let the array be [1,32,4], after dividing each number by 4 our array will become [0, 8, 1].
Now replace the 0 by -1 so that [0, 8, 1] -> [-1, 8, 1].
Hence the modified array will be [-1, 8, 1].
```

Detailed explanation

```
1 <= T <= 100
1 <= N <= 5*10^3
0 <= arr[i] <= 100
Time Limit: 1 sec
```

```
2
2
3 8
3
4 8 12
```

```
-1 2
1 2 3
```

```
Test case 1:
The given array is [3,8]
After dividing each element by 4, our list becomes [0,2].
So as the first element is 0 so replace it with -1.
So, the output is [-1,2].
```

```
2
4
0 0 0 0
1
484
```

```
-1 -1 -1 -1
121
```

```
Test case 1:
The given array is [0,0,0,0]
After dividing each element by 4, our list becomes [0,0,0,0].
So as all the elements are 0 so replace them with -1.
So, the output is [-1,-1,-1,-1].
```