You are viewing a single comment's thread. Return to all comments →
There are two more things have to be done before passing all test cases.
String.split()
List<int[]>
public static void main(String[] args) throws IOException { try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) { int q = Integer.parseInt(bufferedReader.readLine().trim()); int[][] queries = new int[q][2]; for (int i = 0; i < q; i++) { String[] qs = bufferedReader.readLine().split(" "); queries[i][0] = Integer.parseInt(qs[0]); queries[i][1] = Integer.parseInt(qs[1]); } List<Integer> ans = freqQuery(queries); try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")))) { bufferedWriter.write( ans.stream() .map(Object::toString) .collect(joining("\n")) + "\n"); } } }
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
There are two more things have to be done before passing all test cases.
String.split()
instead of pattern match.List<int[]>
to store all queries.