I have a long sequence of order amounts, 1000, 3000, 50000, 1000000, etc.

I want to find out all orders whose amount is more than 100000.

Simplest solution can be iterate through full list and compare and put matched on into another list which will give you all whose amount > 100000.

Do we have any other data structure or algorithm approach which can solve this faster?

The sequence of input elements in unordered.

# Best How To :

The approach that comes to mind could be to keep an ordered list of the orders and perform a binary search for the limit amount. All orders before that point in the ordered list will be less than the limit amount.

```
// Generate a random array of numbers
Random r = new Random();
Integer[] numbers = new Integer[r.nextInt(100) + 20];
for (int i = 0; i < numbers.length; i++) {
numbers[i] = r.nextInt(50000) + 100;
}
// Order the array and print it
Arrays.sort(numbers);
System.out.println(Arrays.toString(numbers));
// Find the index of the amount limit (10000 in this case)
int index = Arrays.binarySearch(numbers, 10000);
// Print the slice of array that is lower than the limit amount
System.out.println(Arrays.toString(Arrays.copyOfRange(numbers, 0, Math.abs(index) + 1)));
```