首页 > 猿辅导笔试第一题
头像
forest0
编辑于 2020-08-22 22:06
+ 关注

猿辅导笔试第一题

有没有大佬知道,我这个代码为什么通不过啊😣
public static List<Integer> boundry(int [] nums){
    int len = nums.length, layers = 0;
    while(len >= Math.pow(2, layers-1))
        layers++;
    layers--;
    List<Integer> L = new ArrayList<>();
    int i = 1, index = 0;
    for( ; i <= layers; ++i){
        index = (int)Math.pow(2, i-1) - 1;
        L.add(nums[index]);
    }
    index++;
    while(index < nums.length){
        L.add(nums[index]);
        index++;
    }
    for(int j = layers-1; j >= 2; --j){
        index = (int)Math.pow(2, j) - 2;
        L.add(nums[index]);
    }
    return L;
}


全部评论

(2) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐