#腾讯笔试# 第一题,又大佬能告诉我为什么我提交了几次在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;
}
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;
}
全部评论
相关推荐
10-23 18:07
辽宁工程技术大学 Web前端 重生之我学Java干...:我从后端的角度分析一下你的第一个项目,我感觉亮点不是很突出。因为我是因为组内有需求,临时上手学react干活。我用到的技术基本就cover你那个智慧园区管理平台的很多亮点了。那作为比较专业的前端,你上述的内容是不是有点单薄呢。感觉还得包装
点赞 评论 收藏
分享
点赞 评论 收藏
分享