public class Main01 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Queue<Integer> queue = new LinkedList<>(); for (int i = 0; i < n; i++) { queue.add(scanner.nextInt()); } int[] out = new int[n]; for (int i = 0; i < n; i++) { out[i] = scanner.nextInt(); } int count = 0; for (int i = 0; i < n-1; i++) { if(out[i]!=queue.peek()){ count++; }else { queue.poll(); } } System.out.println(count); } } 大佬,这样写有什么问题呀。
点赞 4

相关推荐

09-30 15:27
已编辑
成都工业学院 企业文化
Morpheus_:候选人:还需要测验武力值?
投递腾讯等公司10个岗位
点赞 评论 收藏
分享
09-25 00:00
已编辑
电子科技大学 Java
球球与墩墩:这不是前端常考的对象扁平化吗,面试官像是前端出来的 const flattern = (obj) => { const res = {}; const dfs = (curr, path) => { if(typeof curr === 'object' && curr !== null) { const isArray = Array.isArray(curr); for(let key in curr) { const newPath = path ? isArray ? `${path}[${key}]` : `${path}.${key}` : key; dfs(curr[key], newPath); } } else { res[path] = curr } } dfs(obj); return res; }
查看3道真题和解析
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务