guttttzhi
guttttzhi
全部文章
题解
Java专项(1)
归档
标签
去牛客网
登录
/
注册
guttttzhi的博客
全部文章
/ 题解
(共30篇)
题解 | #链表的奇偶重排#
定义两个头节点(奇数位头节点、偶数位头节点),遇到奇数位就加载奇数链表下,遇到偶数位就加载偶数链表 /** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(x), next(nu...
C++
2022-05-25
0
247
题解 | #删除有序链表中重复的元素-II#
主要的思路:创建一个虚拟头结点,目的就是为了找到前驱节点。在移动的过程中如果满足,当前节点的值不等于前驱节点的值,并且不等于后驱节点的值(后驱节点可能为空,为空的情况是满足条件的)。就报该点保留下来。 /** * struct ListNode { * int val; * struct...
C++
2022-05-25
0
316
题解 | #删除有序链表中重复的元素-I#
主要思路:创建一个虚拟头结点,作为前驱节点。依次遍历链表,如果前驱节点和当前节点的值不相等,就将当前节点的值删除掉。直接都进行下移 /** * struct ListNode { * int val; * struct ListNode *next; * }; */ class S...
C++
2022-05-25
0
282
题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率 大致思路:我们只需要关系每天中该用户是否答题,所有我们需要去掉重读的行,将去重的数据作为新的一张表,两次利用该表实现左连接,连接的条件就是时间差为1天。 select COUNT(q2.device_id) / COUNT(q1.device_id) AS av...
Mysql
2022-05-25
0
277
题解 | #统计复旦用户8月练题情况#
统计复旦用户8月练题情况 "复旦大学" as university 起别名的巧用 sum(if(qpd.result = 'right', 1, 0)) 单行函数的嵌套 日期函数 month(qpd.date) = 8 方式一:先在question_practice_detail表中查询mon...
Mysql
2022-05-24
0
228
题解 | #计算用户8月每天的练题数量#
Mysql日期函数的使用 方式一 select dayofmonth(date) day, count(*) question_cnt from question_practice_detail where date like '2021-08%' group by date...
Mysql
2022-05-24
0
236
题解 | #计算25岁以上和以下的用户数量#
CASE When的应用 select CASE when age < 25 or age is null then '25岁以下' when age >= 25 then '25岁及以上' end age_cut, count(*) number f...
Mysql
2022-05-24
0
210
题解 | #统计每个用户的平均刷题数#
统计每个用户的平均刷题数 count(distinct up.device_id) select university, difficult_level, count(qpd.question_id) / count(distinct up.device_id) avg_answer...
Mysql
2022-05-23
0
238
题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数 count(distinct up.device_id) select university,difficult_level,count(qpd.question_id)/count(distinct up.device_id) avg_answer_cnt ...
Mysql
2022-05-23
1
258
题解 | #统计每个学校的答过题的用户的平均答题数#
统计每个学校的答过题的用户的平均答题数 记录一下count(distinct up.device_id) select university,count(question_id) / count(distinct up.device_id) avg_answer_cnt from user_pr...
Mysql
2022-05-23
0
286
首页
上一页
1
2
3
下一页
末页