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.
This code is working for all test cases...if any1 hav any otr idea plz share...thanks.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int t[] = new int[n];
for(int i=0; i < n; i++){
t[i] = in.nextInt();
}
int sum=t[0];
for(int j=1;j=t[j])
sum=sum+1;
else
sum=t[j];
}
System.out.println(sum);
}
Test case #12
9
1 5 5 6 6 7 7 8 8
Correct answer:12. and my answer is 12.
Why am I getting "wrong answer" status?
read n; read n; prev=0; curr=0; for i in curr; curr=prev -ge (( curr;
This code is working for all test cases...if any1 hav any otr idea plz share...thanks.
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int t[] = new int[n]; for(int i=0; i < n; i++){ t[i] = in.nextInt(); } int sum=t[0];
for(int j=1;j=t[j]) sum=sum+1; else sum=t[j]; } System.out.println(sum); }
If I submit the code now will the score be added to my algorithm section score or anywhere else?
can anyone write his code here??after the contest ofcourse..I just wanna take a look at the code as i was unable to complete the problem..:)