建信金科笔试11.19
只做编程
全部评论
#建信金科笔试#
第二题
//删除链表中值为3的倍数的结点
//{2,3,1,5,4,6,3}
//{2,1,5,4}
/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) : val(x), next(nullptr) {}
* };
*/
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param head ListNode类
* @return ListNode类
*/
ListNode* deleteMultipleOf3(ListNode* head) {
// write code here
ListNode root(0);
root.next = head;
ListNode *p = head, *pre = &root;
while(p){
if(p ->val%3 == 0){
pre ->next = p ->next;
delete p;
p = pre ->next;
}
else{
p = p ->next;
pre = pre ->next;
}
}
return root.next;
}
};
第一题
/*一次操作,字符串中所有的大写的字母都要复制一份 k次操作。 求最终的字符串长度
"sABc",2
10
*/
class Solution {
public:
int getLength(string str, int k) {
// write code here
int big=0, small=0;
for(int i=0; i<str.size(); i++)if(str[i]>='A' && str[i]<='Z')big++;else small++;
return small + pow(2,k)*big;
}
};
相关推荐
07-02 18:09
门头沟学院 Java 点赞 评论 收藏
分享
05-09 16:47
南京邮电大学 Java king122:专业技能不要写这么多,熟悉和熟练你经不住问,排版有些难看,中间的空隙搞小一点,项目描述的话感觉是从课程中抄下来的,改一改吧,不然烂大街了,每个项目都写一两点,用什么技术实现了什么难点,然后再写一些数字上去像时间又花了90%这样,这样面试会多一些,如果觉得自己的项目还是不够用的话,我有几个大厂最近做过的实习项目,感兴趣的话可以看我简介中的项目地址
点赞 评论 收藏
分享
点赞 评论 收藏
分享