You are viewing a single comment's thread. Return to all comments →
public static List dynamicArray(int n, List> queries) { List lastAnswers = new List();
int lastAnswer = 0; List<List<int>> seqList = new List<List<int>>(); for (int i = 0; i < n; i++){ seqList.Add(new List<int>()); } foreach (var query in queries){ int index = (query[1]^lastAnswer) % n; if(query.First() == 1){ seqList[index].Add(query.Last()); } else{ int x = query.Last(); int size = seqList[index].Count; lastAnswer = seqList[index][x % size]; lastAnswers.Add(lastAnswer); } } return lastAnswers; }
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 →
public static List dynamicArray(int n, List> queries) { List lastAnswers = new List();