You are viewing a single comment's thread. Return to all comments →
Using JAVA
This is easy problem but I enjoyed to solve,
int lastAnswer = 0; List<Integer> result= new ArrayList<Integer>(); List<List<Integer>> arr = new ArrayList<>(n); for(int i=0;i<n;i++){ arr.add(new ArrayList<Integer>()); } for(int j=0; j<queries.size();j++){ int x = queries.get(j).get(1); int y= queries.get(j).get(2); int idx = ((x ^ lastAnswer)%n); if(queries.get(j).get(0) == 1){ arr.get(idx).add(y); }else{ lastAnswer = arr.get(idx).get(y%(arr.get(idx).size())); result.add(lastAnswer); } } return result; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Dynamic Array
You are viewing a single comment's thread. Return to all comments →
Using JAVA
This is easy problem but I enjoyed to solve,
}