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.
Yup. Sample Test #2 when you "Run", Test #5 when you submit.
It should be corrected but here is an easy Java workaround:
int n = scanner.nextInt();
int[] arr = new int[n];
int i = 0;
try{
for (; i < n; i++) {
arr[i] = scanner.nextInt();
}
} catch(NoSuchElementException ex){
arr = Arrays.copyOf(arr, i);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Closest Numbers
You are viewing a single comment's thread. Return to all comments →
Yup. Sample Test #2 when you "Run", Test #5 when you submit. It should be corrected but here is an easy Java workaround: