Array Size doubt

how to handle array size

see the Constraints

1<=length of array<=10^4

max size of array can be 10^4
so take size of array =10^4

in sample input ,size is not shown

Exception in thread “main” java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:864) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Main.main(Main.java:7)

you can take size of array to 10^4

10^4 was not working . I have taken as n still not working, pls check https://ide.codingblocks.com/s/477834

reply…

at line no 7
n=sc.nextInt();

this is incorrect because n is not given to you
so you have to take n=10^4 which is max value of n

in input brackets and commas are also present
[23,2,4,6,7]
6

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.