首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
基础学习课
实战项目课
求职辅导课
专栏&文章
竞赛
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
AI面试、笔试、校招、雇品
HR免费试用AI面试
最新面试提效必备
登录
/
注册
听海时节
2017-09-20 21:07
香港科技大学 Java
关注
已关注
取消关注
华为第三道题目
第三题怎么改都只有37.5,有大佬100AC的吗,要求的输出顺序到底是什么呀?大雾
提示
全部评论
推荐
最新
楼层
SUPERKCH
中山大学 C++
75% +1. 检查半天看不出漏了哪种情况,题名还特意说明 没有非法输入。 最逗的是题目要求按升序,而例子是降序。
点赞
回复
分享
发布于 2017-09-20 21:22
Jenson
上海交通大学 Java
#include <iostream> #include <cstring> #include <string> #include <cstdlib> #include <cstdio> #include <vector> #include <stack> #include <algorithm> #include <set> #include <queue> #include <cctype> #include <cmath> #include <map> #include <unordered_map> #include <deque> #include <sstream> using namespace std; void replace(string str, const string &bitset, unordered_map<int, int> &record, char nc){ bool flag = false; int idx = 1; int i = bitset.size() - 1; while(i >= 0) { if(bitset[i] == '1') { int strIdx = record[idx]; str[strIdx] = nc; flag = true; } --i; ++idx; } if(flag) { cout << ',' << str; } } bool nextBitSet(string &bitset) { const int len = bitset.size(); if(bitset[len-1] == '0') { bitset[len-1] = '1'; return true; } int curIdx = len-1; while(curIdx >= 0) { if(bitset[curIdx] == '0') { bitset[curIdx] = '1'; break; } bitset[curIdx--] = '0'; } if(curIdx < 0) return false; return true; } int main() { string str; char oc, nc; cin >> str >> oc >> nc; oc = tolower(oc); unordered_map<int, int> record; const int len = str.size(); int idx = 1; int maxIdx = -1; bool found = false; for(int i = len-1; i >= 0; --i) { char ch = tolower(str[i]); if(ch == oc) { found = true; record[idx++] = i; maxIdx = (idx > maxIdx? idx : maxIdx); } } if(found) { string bitset(maxIdx-1, '0'); cout << str; while(nextBitSet(bitset)) { replace(str, bitset, record, nc); } cout << endl; }else{ cout << str << endl; } return 0; } 100%通过
点赞
回复
分享
发布于 2017-09-20 21:19
每天学一点
杭州电子科技大学 Java
public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); String str = s.nextLine(); String[] strings = str.split(" "); TreeSet<String> ts = new TreeSet<String>(new Comparator<String>(){ @Override public int compare(String o1, String o2) { return o2.compareTo(o1); } }); ts.add(strings[0]); new Test3().swap(ts,strings[0],strings[1],strings[2]); String last = ts.pollLast(); for (String string : ts) { System.out.print(string+","); } System.out.println(last); s.close(); } public TreeSet<String> swap(TreeSet<String> ts,String str1,String str2,String str3){ for (int i = 0; i < str1.length(); i++) { if(str2.equals(str1.charAt(i)+"")){ StringBuilder sb = new StringBuilder(str1); String string = sb.replace(i, i+1, str3).toString(); ts.add(string); swap(ts,string,str2,str3); } } return ts; } } 不知道对错啊,大神帮看一看
点赞
回复
分享
发布于 2017-09-20 21:18
Superninesun
杭州电子科技大学 C++
// 华为第三题.cpp : 定义控制台应用程序的入口点。// include "stdafx.h" include <iostream> include <string> include <vector> using namespace std; int main(){ string input; string src; string dest; cin >> input>>src>>dest; string mytemp; int num = 0; for (int i = 0; i < input.size(); i++) { if (input[i] == src[0]) { num++; mytemp.push_back('0'); } } string stard; for (int i = 0; i < num; i++) { stard.push_back('1'); } vector<string> res; for (int i = 0; i < pow(2, num); i++) { string restemp = input; int cnt = 0; for (int j = 0; j < input.size(); j++) { if (restemp[j] == src[0]) { if (src[0] > dest[0]) { if (mytemp[cnt] == '1') { restemp[j] = dest[0]; } } else { if (mytemp[cnt] == '0') { restemp[j] = dest[0]; } } cnt++; } } res.push_back(restemp); int k = 1; int jinwei = 1; while (jinwei == 1 && mytemp!=stard) { if (mytemp[num - k] == '0') { mytemp[num - k] = '1'; k++; jinwei = 0; } else if (mytemp[num - k] == '1') { mytemp[num - k] = '0'; jinwei = 1; k++; } } } for (int i = 0; i < res.size()-1; i++) { cout << res[i] <<','; } cout << res[res.size() - 1] << endl; cin.get(); cin.get(); return 0; }
点赞
回复
分享
发布于 2017-09-20 21:13
Kay_sysu2017
腾讯_云产品部_前端工程师
75%的路过。
点赞
回复
分享
发布于 2017-09-20 21:11
L.W.M
同济大学 算法工程师
没用一题100AC 也是服了
点赞
回复
分享
发布于 2017-09-20 21:11
小亮邱
浙江大学 Java
百分之75路过。。
点赞
回复
分享
发布于 2017-09-20 21:09
暂无评论,快来抢首评~
相关推荐
07-08 10:56
湘潭大学 招聘专员
25届毕业现在在家呆了一个多月,没工作
毕业到现在一个月,完全不知道该往什么方向发展,父母希望在家附近找个工作我们家在小县城附近基本没有什么工作,但是自己又没有勇气一个人去面对一个人去大城市感觉我的人生完蛋惹!
码农索隆:
要是想待在小县城的话,就考公吧
点赞
评论
收藏
分享
不愿透露姓名的神秘牛友
07-10 11:11
26届第一个offer/京东的jds
路径是实习评价A拿到的面试直通卡,今天下午刚面完晚上就发offer了。
点赞
评论
收藏
分享
05-26 13:22
西安电子科技大学 算法工程师
今年就业形势怎么样?
大家觉得难不难呢?
强大的马里奥:
不太可能,我校计算机硕士就业率99%
点赞
评论
收藏
分享
不愿透露姓名的神秘牛友
07-11 15:37
国企实习第三天,对后端开发失去信心
java后端开发,读研期间自学的java,也没太多实操经验,今天第三天带教老师给了我一个项目的代码让我自己试试实现其中的一些功能,然而这个项目干嘛的我要开发哪里我都还云里雾里,做研发的实习生还就我一个女生平时连饭搭子都没,有点怀疑自己做不来技术了.....
程序员小白条:
还是那句话,实习不懂就问,饭搭子这玩意看人的,实习生要是就一个,那你咋整,有些东西非必要,实习主要看自己适应能力,否则正式了,你更适应不过来,毕竟上班和上学可不一样
实习生的蛐蛐区
点赞
评论
收藏
分享
评论
点赞成功,聊一聊 >
点赞
收藏
分享
评论
提到的真题
返回内容
全站热榜
更多
1
...
入职云智一个月~希望消除大家对云智的误解
7145
2
...
大厂工作一年了,给想进游戏行业的朋友们写点体会
4230
3
...
学历厂大点兵
3501
4
...
袋鼠云Java一面
3346
5
...
两年后重看秋招——后悔选择读研,可到底该怎么做?
2401
6
...
从实习开始,我就长大了
2192
7
...
北京租房房租问题,应该花1000或者低于1000租吗
2098
8
...
字节客户端一面
2003
9
...
28届双非本快手实习一周感受~
1532
10
...
真的打了那个电话后才觉无力
1493
创作者周榜
更多
正在热议
更多
#
你认为小厂实习有用吗?
#
24580次浏览
268人参与
#
技术岗笔试题求解
#
76434次浏览
977人参与
#
如果公司给你放一天假,你会怎么度过?
#
15461次浏览
111人参与
#
说说你知道的学历厂
#
46916次浏览
280人参与
#
实习生的蛐蛐区
#
62305次浏览
447人参与
#
三一重工求职进展汇总
#
13868次浏览
62人参与
#
秋招最大的收获是什么?
#
36488次浏览
311人参与
#
哪一瞬间觉得自己长大了
#
11820次浏览
256人参与
#
面试尴尬现场
#
37298次浏览
242人参与
#
计算机有哪些岗位值得去?
#
19249次浏览
167人参与
#
材料人,你们签了哪个公司
#
7860次浏览
18人参与
#
你找工作的时候用AI吗?
#
21653次浏览
254人参与
#
下班后的时间你怎么安排
#
11846次浏览
155人参与
#
社会教会你的第一课
#
41629次浏览
516人参与
#
电网笔面经互助
#
37324次浏览
360人参与
#
你的领导最像哪种动物,为什么?
#
14923次浏览
107人参与
#
机械专业只有考研才有出路吗
#
115794次浏览
880人参与
#
运营面经
#
116247次浏览
1254人参与
#
lastday知无不言
#
58865次浏览
476人参与
#
总结:哪家公司面试体验感最差
#
59951次浏览
268人参与
牛客网
牛客网在线编程
牛客网题解
牛客企业服务