百度笔试 1.6 / 3
1、第一题: 100%
找了一下规律,如下:
定义 long max = (n + 1) / 2
1~1: 1-1
1~2: 1-2 2-1
1~3:1-1 2-2 3-1
1~4:1-1 2-2 3-2 4-1
1~5:1-1 2-2 3-3 4-2 5-1
1~6: 1-1 2-2 3-3 4-3 5-2 6-1
if(k<=max) sout(k)
else if(n%2==0) sout(max-(k-max-1))
else sout(max(k-max))
2、第二题 60%
String str = in.next();
int length = str.length();
char[] chs = str.toCharArray();
for(int i = 0; i < length - 1; i++) {
char end = chs[length - 1];
chs[length - 1] = chs[i];
for(int j = i; j < length - 2; j++) chs[j] = chs[j + 1];
chs[length - 2] = end;
}
String result = new String(chs);
System.out.print(result);
3、第三题:想起来了JJ的“总是学不会 再聪明一点~”
#百度#
找了一下规律,如下:
定义 long max = (n + 1) / 2
1~1: 1-1
1~2: 1-2 2-1
1~3:1-1 2-2 3-1
1~4:1-1 2-2 3-2 4-1
1~5:1-1 2-2 3-3 4-2 5-1
1~6: 1-1 2-2 3-3 4-3 5-2 6-1
if(k<=max) sout(k)
else if(n%2==0) sout(max-(k-max-1))
else sout(max(k-max))
2、第二题 60%
String str = in.next();
int length = str.length();
char[] chs = str.toCharArray();
for(int i = 0; i < length - 1; i++) {
char end = chs[length - 1];
chs[length - 1] = chs[i];
for(int j = i; j < length - 2; j++) chs[j] = chs[j + 1];
chs[length - 2] = end;
}
String result = new String(chs);
System.out.print(result);
3、第三题:想起来了JJ的“总是学不会 再聪明一点~”
#百度#
全部评论

虽然我1.6,但是我学会了打麻将
第三题我是先选个对子,然后回溯加刻子,到长度14的时候去个重。
a了 1.83333,第三题没想出来
第三题不会,小于4为0,等于4为10,骗到了10%
第三题过了20%,但是超时了😂
第二题a了,剩下寄
第二题超时了
跟你一模一样兄弟,第三题return测例骗了10%

打表ak了
第二题用链表模拟过了(python)
相关推荐

点赞 评论 收藏
分享


米哈游
| 实习
| 超多精选岗位
点赞 评论 收藏
分享