How to read multiple Integer values from a single line of input in Java?
I use it all the time on hackerrank/leetcode BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String lines = br.readLine(); String[] strs = lines.trim().split(“\\s+”); for (int i = 0; i < strs.length; i++) { a[i] = Integer.parseInt(strs[i]); }