We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int N= sc.nextInt();
int q=sc.nextInt();
int lastAnswer=0;
int x=1;
int a[] [] = new int[q][3];
List> seqList = new ArrayList>();
for(int i=0;i
}
x=(a[i][1]^lastAnswer%N);
if(a[i][0]==1)
{
seqList.add(new ArrayList<Integer>());
seqList.get(x).add(a[i][2]);
}
else
{
int s = seqList.get(x).size() - 1;
lastAnswer =seqList.get(x).get(s);
if(lastAnswer!=0)
System.out.println(lastAnswer);
}
}
}
}
what is wrong with this code as it is giving only one positive test case?????
Cookie support is required to access HackerRank
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 →
import java.io.; import java.util.;
public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int N= sc.nextInt(); int q=sc.nextInt(); int lastAnswer=0; int x=1; int a[] [] = new int[q][3]; List> seqList = new ArrayList>(); for(int i=0;i