#腾讯笔试#  第一题,又大佬能告诉我为什么我提交了几次在20%-100%之间浮动么😅
    public ListNode[] solve (int m, ListNode a) {
        // write code here
        ListNode res[] = new ListNode[m];
        ListNode next[] = new ListNode[m];
        ListNode cur = a;
        while (cur != null) {
            int index = cur.val % m;
            ListNode tmp = new ListNode(cur.val);
            if (res[index] == null) {
                res[index] = tmp;
                next[index] = tmp;
            }
            else {
                next[index].next = tmp;
                next[index] = tmp;
            }
            cur = cur.next;
        }
        return res;
    }
全部评论

相关推荐

SHC2:关键问题是你这三段实习是三个不同的岗位…你这样子秋招就是只有一段实习的本科生..
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务