Why is this code giving wrong answer? I used two queues and proceeded with the same algorithm given in the editorial. Plz help.
import java.util.*;class COOK82C {public static void main(String args[]) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();Queue<Integer> q1 = new LinkedList<>();Queue<Integer> q2 = new LinkedList<>();for(int i = 0; i < n; i++) {int a = sc.nextInt();q1.add(a);}int dd[] = new int[m];for(int i = 0; i < m; i++) {int x = sc.nextInt();dd[i] = x;}
Read more… (23 words)