# Airbnb Code Challenge 12

``````    static class DataEntry{
int index;
int floorVal;
double diff;
public DataEntry(int index, int floorVal, double differenceFromFloor){
this.index = index;
this.floorVal = floorVal;
this.diff = differenceFromFloor;
}
}

public static List<Integer> Solution5(List<Double> prices, int target){
DataEntry[] entries = new DataEntry[prices.size()];
int floorSum = 0, xFloor;
double x;
for(int i=0; i<prices.size(); i++){
x = prices.get(i);
xFloor = (int)x;
floorSum += xFloor;
DataEntry newDataEntry = new DataEntry(i, xFloor, x - xFloor);
entries[i] = newDataEntry;
}

int totalDiff = target - floorSum;
Arrays.sort(entries, (a, b) -> a.diff >= b.diff ? -1 : 1); // sort entries according to difference

int idx = 0;
while(idx < totalDiff){
entries[idx] = new DataEntry(entries[idx].index, entries[idx].floorVal+1, entries[idx].diff); // add 1 to the first diff entries
idx++;
}

Arrays.sort(entries, (a, b) -> a.index < b.index ? -1 : 1); // sort entries according to original idx

List<Integer> result = new ArrayList();
for(int i=0; i<prices.size(); i++){