2
public int[] processQueries(int[] queries, int m) {3
int[] results = new int[queries.length];4
ArrayList<Integer> permutations = new ArrayList<Integer>();6
// Filling the permuations array with numbers.7
for (int i = 0; i < m; i++) permutations.add(i + 1);9
// Looping on the queries & checking their index in the permuations10
for (int i = 0; i < queries.length; i++) {11
int query = queries[i];12
for (int j = 0; j < permutations.size(); j++)13
if (permutations.get(j) == query) {15
int temp = permutations.get(j);16
permutations.remove(j);17
permutations.add(0, temp);