阿里笔试

如题#阿里巴巴##笔试题目#
全部评论
第一题我也0了,最后的时候想了一下是不是可能是因为判题数据的到达时间不是升序?
1
送花
回复 分享
发布于 2021-04-09 20:04
第一题一开始图方便,用个sort排序不出来,然后用priority_queue还是出不来,阿里的题看起来思路不难,每次写出0来,求朋友们解答。
1
送花
回复 分享
发布于 2021-04-09 20:06
神州信息
校招火热招聘中
官网直投
大佬们第一题就是0,求个题解,我很纳闷
点赞
送花
回复 分享
发布于 2021-04-09 19:59
第二题超时,只会用笨方法每次直接交换,哪个大佬能告知下思路ww,或者贴个java的解法,谢谢了
点赞
送花
回复 分享
发布于 2021-04-09 20:03
优先队列保存序号,然后模拟也是0
点赞
送花
回复 分享
发布于 2021-04-09 20:10
第一题过的老哥,发份pasteubuntu的代码链接吧
点赞
送花
回复 分享
发布于 2021-04-09 20:13
#include<iostream> #include<vector> #include<algorithm> #include<queue> using namespace std; struct time { int start; int end; int num; }; struct cmp{  bool operator()(const time a,const time b){ if (a.start == b.start)return a.num > b.num; return a.start > b.start; } }; int main() { int t; cin >> t; while (t--) { int n; cin >> n; priority_queue<time, vector<time>, cmp> q; for (int i = 0; i < n; i++) {                        time temp; cin >> temp.start >> temp.end; temp.num = i; q.push(num1[i]); } vector<int> list(n, 0); time temp = q.top(); q.pop(); list[temp.num] = temp.start; int pre = temp.start + 1; for (int i = 1; i < n; i++) { time temp = q.top(); q.pop(); if (pre >= temp.end)continue; list[temp.num] = max(temp.start, pre); pre = max(temp.start, pre) + 1; } for (int i = 0; i < n; i++) { cout << list[i] << " "; } cout << endl; } return 0; } 有没有朋友看看代码存在的问题
点赞
送花
回复 分享
发布于 2021-04-09 20:13
第一题0%,原因竟然是输出不是按照学生序号输出的,而是按照学生排队的顺序😓
点赞
送花
回复 分享
发布于 2021-04-09 20:20
阿里卡笔试吗,佬们
点赞
送花
回复 分享
发布于 2021-04-09 20:41

相关推荐

ztqiuzhi:直接回,现在已经到你们公司楼下了哦
点赞 评论 收藏
分享
1 2 评论
分享
牛客网
牛客企业服务