My program runs exactly as expected. It runs fine on Intellij, but when I go to submit it for verification, it times out every time. So I ran it here, on this website, and it, again, runs just fine. I submit it for verification, and it says I have an infinite loop.
????
What the heck is going on?
Also, is there a better place to submit questions like this? Should I have messaged an admin?
package com.codegym.task.task07.task0714;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/*
Words in reverse
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < 5; i++) {
list.add(reader.readLine());
}
list.remove(2);
ArrayList<String> reverse = reverseList(list);
printList(reverse);
}
public static ArrayList<String> reverseList(ArrayList<String> list) {
ArrayList<String> reverse = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
reverse.add(list.get(list.size()-i-1));
}
return reverse;
}
public static void printList(ArrayList<String> reverse) {
for (int i = 0; i < reverse.size(); i++) {
System.out.println(reverse.get(i));
}
}
}