You are viewing a single comment's thread. Return to all comments →
Just add one line to your solution to make it more efficient:
public static void main(String[] args) {
Scanner in = new Scanner(System.in); int goal = in.nextInt(); in.nextInt(); int counter = 0; while(in.hasNextInt()){ if(in.nextInt() == goal) { System.out.println(counter); break; } counter += 1; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Intro to Tutorial Challenges
You are viewing a single comment's thread. Return to all comments →
Just add one line to your solution to make it more efficient:
public static void main(String[] args) {
}