import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param students int整型一维数组 * @param sandwiches int整型一维数组 * @return int整型 */ public int countStudents (int[] students, int[] sandwiches) { // write code here List<Integer> zhanxue = new ArrayList<>(); List<Integer> san = new ArrayList<>(); for(int i = 0; i<students.length;i++){ zhanxue.add(students[i]); } for(int i = 0; i<sandwiches.length;i++){ san.add(sandwiches[i]); } int count = 0; while(zhanxue.size()>0 && san.size()>0 && count<zhanxue.size()){ if(zhanxue.get(0) == san.get(0)){ zhanxue.remove(0); san.remove(0); count=0; System.out.println("0xue:"+zhanxue.toString()+",0san:"+san.toString()); }else { zhanxue.add(zhanxue.get(0)); zhanxue.remove(0); count++; System.out.println("1xue:"+zhanxue.toString()+",1san:"+san.toString()); } } return zhanxue.size(); } }