Error in Container Containing Problem

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
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:9)
The code:
import java.uitl.*;
public class Main {
public static void main (String args[]) {

int i;
int n;
Scanner s = new Scanner(System.in);

    n = s.nextInt();
    int a[] = new int[n];
   
    for( i = 0; i<n; i++)
    {
        a[i] = s.nextInt();
   
    }

int left=0,right=n-1;
int area=0;
while(left<right)
{
area=Math.max(area,(Math.min(a[left],a[right])*(right-left)));
if(a[left]<a[right]){
left=left+1;
}
else{
right=right+1;
}
}
System.out.println(area);
}
}

hello @sravanthikaki
ur logic is correct,
is this code working on ur local ide.

Yes Aman its working

this should be right=right-1;

ohh thanks thanks!! it was by mistake

Aman, now the code works fine in my local ide but here thisis what it says Main.java:6: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:6: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors

try this -> https://ide.codingblocks.com/s/252235
also make sure u have set the language as java

Sorry to trouble you Aman. I tried executing the code through the link you gave me and I also made sure taht the language is set to JAVA this is what ot says:Exception in thread “main” java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:862) 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:9)

try submitting here -> https://hack.codingblocks.com/app/contests/1290/1505/problem

it is working fine
image

In Hackerblocks it worked fine and passed all the test cases.

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.