其他分享
首页 > 其他分享> > leetcode1033-移动石子直到连续

leetcode1033-移动石子直到连续

作者:互联网

移动石子直到连续

class Solution {
    public int[] numMovesStones(int a, int b, int c) {
        if(a > b){int t = a; a = b; b = t;}
        if(a > c){int t = a; a = c; c = t;}
        if(b > c){int t = b; b = c; c = t;}
        int num1 = b-a-1, num2 = c-b-1;
        int min = 0, max = 0;
        if(num1 == 1 || num2 == 1)  min = 1;
        else    min = Math.min(num1, 1)+Math.min(num2, 1);
        max = num1+num2;
        return new int[]{min, max};
    }
}

标签:num1,num2,min,leetcode1033,max,石子,int,移动,Math
来源: https://www.cnblogs.com/xzh-yyds/p/16592866.html