603. 连续空余座位难度:简单

1、题目描述

在这里插入图片描述
来源:力扣(LeetCode)

2、解题思路

两表联查,记得去重distinctc2.seat_id

3、提交记录

select distinct c2.seat_id
from cinema c1,cinema c2
where c1.free=True and c2.free=True and
(c1.seat_id-c2.seat_id=1 or
c2.seat_id-c1.seat_id=1)

430ms

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
@RequestMapping("/systemChange") public String systemChange(String id) { Student student = studentService.getById(id); LambdaQueryWrapper<Student> studentLambdaQueryWrapper = new LambdaQueryWrapper<>(); studentLambdaQueryWrapper.eq(Student::getSex,student.getSex()); //存在班级就寻找班级的学生 if (!ObjectUtils.isEmpty(student.getGrade())){ studentLambdaQueryWrapper.eq(Student::getCollege,student.getGrade()); } //并且存在宿舍的 studentLambdaQueryWrapper.isNotNull(Student::getDormitoryId); List<Student> studentList = studentService.list(studentLambdaQueryWrapper); //查出自己的文件答案 LambdaQueryWrapper<TopicResult> topicResultLambdaQueryWrapper = new LambdaQueryWrapper<>(); topicResultLambdaQueryWrapper.eq(TopicResult::getStuNum, student.getStudentNumber()) .and(qw -> qw.eq(TopicResult::getTopicId, 1).or().eq(TopicResult::getTopicId, 2)); List<TopicResult> topicResults = topicResultService.list(topicResultLambdaQueryWrapper); for (Student student1 : studentList) { LambdaQueryWrapper<TopicResult> topicResultLambdaQueryWrapper1 = new LambdaQueryWrapper<>(); topicResultLambdaQueryWrapper1.eq(TopicResult::getStuNum, student1.getStudentNumber()) .and(qw -> qw.eq(TopicResult::getTopicId, 1).or().eq(TopicResult::getTopicId, 2)); List<TopicResult> results = topicResultService.list(topicResultLambdaQueryWrapper1); if (topicResults.get(0).getOptionId().equals(results.get(0).getOptionId()) || topicResults.get(1).getOptionId().equals(results.get(1).getOptionId()) ){ Dormitory dormitory = dormitoryService.getById(student1.getDormitoryId()); if (dormitory.getNum()<dormitory.getTotal()){ student.setDormitoryId(dormitory.getId()); studentService.updateById(student); dormitory.setNum(dormitory.getNum()+1); dormitoryService.updateById(dormitory); return "redirect:list"; } } }请详细解释每一行代码
最新发布
05-19

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值