I am trying to solve a problem with Java and the input is a string of 15 characters for example. when I use a scanner
to read it using the method nextLine()
it doesn't work because the input string doesn't have a \n
in the end
for example the input is :
15 3
cccaabababaccbc
my code :
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = s.nextInt();
String temp = s.nextLine();
temp = s.next();
note that I read the temp twice to get the \n
in the end of the first line.the problem link and my submission is
here