I am exploring ways to efficiently solve this particular problem.
Within my dataset is an extensive array of integers:
[170,158,147,139,134,132,133,136,141,.....]
I have predetermined threshold values of 132
and 137
.
My goal is to adjust any numbers in the array that are below 132
to a new value, such as 100
, and change any number above 137
to another value, like 150
.
One approach could be to create a function:
for (i < array.length)
if(array[i] < 132)
array[i] = 100;
if(array[i] > 137)
array[i] = 150
However, with the size of my array being over 20k elements, this method would be time-consuming due to the numerous conditional statements.
The order of the array must be maintained, eliminating the possibility of sorting.
Perhaps utilizing bitwise operations could provide a more efficient solution for this task.