层级遍历 import java.util.LinkedList; import java.util.Scanner; public class Main {    public static void main(String[] args) {       Scanner in = new Scanner(System.in);       String s = in.next();       String[] split = s.split(",");       int x = Integer.valueOf(split[0]);       int y = Integer.valueOf(split[1]);       LinkedList<Integer> list = new LinkedList<>();       int times = 0;       int count = 0;       int temp = x;       while(temp != y) {           list.add(temp+1);           list.add(temp-1);           list.add(temp*2);           if(count == 0) {               count = list.size();               times++;           }           temp = list.removeFirst();           count--;       }       System.out.println(times);    } }
点赞 1

相关推荐

07-15 14:14
门头沟学院 Java
7.10投递7.15感谢信
投递地平线等公司7个岗位
点赞 评论 收藏
分享
07-18 10:39
门头沟学院 Java
点赞 评论 收藏
分享
06-26 22:20
门头沟学院 Java
码农索隆:让你把简历发给她,她说一些套话,然后让你加一个人,说这个人给你改简历,然后开始卖课
我的求职精神状态
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务