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 ...
随机推荐
- C#之Socket断线重连
一.网上常用方法 1.当Socket.Conneted == false时,调用如下函数进行判断 /// /// 当socket.connected为false时,进一步确定下当前连接状态 /// / ...
- 转【C#调用DLL的几种方法,包括C#调用C\C++\C#DLL】
C#中dll调用方法 一. DLL与应用程序 动态链接库(也称为DLL,即为“Dynamic Link Library”的缩写)是Microsoft Windows最重要的组成要素之一, ...
- ubuntu - 14.04,安装Go语言(谷歌公司开发的一种语言)
Go语言下载地址:https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz 安装: 1,以root身份在shell里执行: ta ...
- Nginx部署静态页面及引用图片有效访问的两种方式
nginx安装百度一下有很多,直接正题: 静态文件目录结构 file#文件位置 /home/service/file/ css js images html fonts 配置nginx.conf核心代 ...
- 算法训练 Pollution Solution(计算几何)
问题描述 作为水污染管理部门的一名雇员,你需要监控那些被有意无意倒入河流.湖泊和海洋的污染物.你的其中一项工作就是估计污染物对不同的水生态系统(珊瑚礁.产卵地等等)造成的影响. 你计算所使用的模型已经 ...
- [SinGuLaRiTy] 贪心题目复习
[SinGuLaRiTy-1024] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 2709] 颜料 (Painter) 题目描述 ...
- 老男孩Day3作业:工资管理系统
作业需求: 1.从info.txt文件中读取员工及其工资信息,最后将修改或增加的员工工资信息也写入原info.txt文件. 2.能增查改员工工资 3.增.改员工工资用空格分隔 4.实现退出功能 1)编 ...
- 2019.2.25考试T3, 离线+线段树
\(\color{#0066ff}{题解}\) #include<bits/stdc++.h> #define LL long long LL in() { char ch; LL x = ...
- mybatis逆向工程工具
mybatis逆向工程 package com.cxy; import java.io.File; import java.util.*; import org.mybatis.generator.a ...
- FPGA实战操作(1) -- SDRAM(Verilog实现)
对SDRAM基本概念的介绍以及芯片手册说明,请参考上一篇文章SDRAM操作说明. 1. 说明 如图所示为状态机的简化图示,过程大概可以描述为:SDRAM(IS42S16320D)上电初始化完成后,进入 ...