public class Solution {
public static void main(String[] args) throws IOException,NumberFormatException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] first_line = new int[2];
String line = br.readLine();
String[] strs = line.trim().split("\\s+");
for(int i=0;i<2;i++)
{
first_line[i] = Integer.parseInt(strs[i]);
}
int num = first_line[0];
int tc = first_line[1];
int[] lane = new int[num];
String sec_line = br.readLine();
String[] strs_line = sec_line.trim().split("\\s+");
for(int i=0;i<num;i++)
{
lane[i] = Integer.parseInt(strs_line[i]);
}
for(int i=0;i<tc;i++)
{
String io = br.readLine();
String[] ee = io.trim().split("//s+");
int entry = Integer.parseInt(ee[0]);;// This is where my program throws exception
int exit = Integer.parseInt(ee[1]);
findMin(lane,entry,exit);
}
}
public static void findMin(int[] lane,int entry,int exit)
{
int min = entry;
for(int i=entry+1;i<exit;i++)
{
if(lane[i] < min)
{
min = lane[i];
}
}
System.out.println(min);
}
}
0 3
4 6
6 7
3 5
0 7
Each pair separated by space are the various entry and exit points in the lane but when i try to read this it throws an NumberFormatException
Change your regex from
String[] ee = io.trim().split("//s+");
to
String[] ee = io.trim().split("\\s+");