leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度
https://leetcode.com/problems/employees-earning-more-than-their-managers/description/

老师上课没分析这些的复杂度,我大概认为子查询要O(n^2)
一开始,直接用了子查询,2400ms....
# Write your MySQL query statement below
select T.name as Employee
from Employee as T
where T.Salary > (select Employee.salary from Employee where Employee.Id = T.ManagerId);
然后
标程有一个2000ms的,但我也认为他复杂度需要O(n^2)
SELECT
a.Name AS 'Employee'
FROM
Employee AS a,
Employee AS b
WHERE
a.ManagerId = b.Id
AND a.Salary > b.Salary
;
最后一个用了join,确实理论上会比较快一丢丢,但是总体来说我感觉还是O(n^2)啊,1800ms快了很多很多
SELECT
a.Name AS 'Employee'
From
Employee as a join Employee as b
on a.ManagerId = b.Id
where
a.Salary > b.Salary
;
leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度的更多相关文章
- Leetcode 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode 181. Employees Earning More Than Their Managers (超过经理收入的员工)
题目标签: 题目给了我们一个 员工表,包括经理.员工会有经理的id. 这里可以重复 利用两次 表格,表格a, 表格b,当a 员工的经理id 等于 b员工时候,在从中找到员工工资大于经理的.具体看co ...
- [LeetCode] 181. Employees Earning More Than Their Managers_Easy tag: SQL
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- 【SQL】181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode SQL:Employees Earning More Than Their Managers
# Write your MySQL query statement below SELECT a.Name FROM Employee AS a INNER JOIN Employee AS b O ...
- [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode - Employees Earning More Than Their Managers
Description: The Employee table holds all employees including their managers. Every employee has an ...
- LeetCode——Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
随机推荐
- 找BUG
找一找BUG 一段代码,实现一个pop,push,和getmin都是O(1)的方法. 最初源代码 伙伴代码如下,代码的地址可以通过这个访问: Ubuntu Pastebin https://paste ...
- web.xml文件的Url-pattern 节点配置
- SQLServer存储引擎——04.数据
4. SQL SERVER存储引擎之数据篇 (4.1)文件 (0)主数据文件.mdf初始文件大小至少为3MB,次要数据文件.ndf初始大小,同日志文件一样至少为512KB: (1)SQL SERVER ...
- android studio 程序员有福了—从layout自动生成viewholder类
狂点这里下载 超级牛逼的插件啊,比那些使用SparseArray的强太多了! 在android studio 1.0上测试,没有问题. 不说了直接说功能 Android Toolbox Plugin ...
- tomcat - 认识
tomcat - web应用服务器 环境:ubuntu测试 @shell命令(cd到tomcat目录下) 启动: ./bin startup.sh 关闭:./bin shutdown.sh @部署 ...
- ubuntu - 14.04,必须会的技能-安装PPA源中的程序,更大范围使用deb格式安装文件!!
在使用ubuntu时候,管理各种软件最方便的方式肯定是使用软件中心了,这个管理工具类似windows的 程序管理了,使用它有两个好处: 1,无需处理包依赖,linux里面程序存在各种依赖关系,这在以往 ...
- numpy中argsort函数用法
在Python中使用help帮助 >>> import numpy >>> help(numpy.argsort) Help on function argsort ...
- 【OD深入学习】Java多线程面试题
一.参考文章 1. Java线程面试题 Top 50 2. Java面试——多线程面试题 3. JAVA多线程和并发基础面试问答 4. 15个顶级Java多线程面试题及回答 二.逐个解答 三.一语中的 ...
- 【bzoj2242】: [SDOI2011]计算器 数论-快速幂-扩展欧几里得-BSGS
[bzoj2242]: [SDOI2011]计算器 1.快速幂 2.扩展欧几里得(费马小定理) 3.BSGS /* http://www.cnblogs.com/karl07/ */ #include ...
- [转]关于TDD、BDD和DDD的一些看法
在实际的项目中,我们可能随时面对各种不同的需求,它的各个方面的要素决定了我们所采用的开发模式. 比如,它的复杂度如何?所有的需求是否足够清晰?开发人员对相关的业务是否足够了解?项目的工期是否合理?种种 ...