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 ...
随机推荐
- HTML5应用程序缓存Application Cache详解.RP
什么是Application Cache HTML5引入了应用程序缓存技术,意味着web应用可进行缓存,并在没有网络的情况下使用,通过创建cache manifest文件,可以轻松的创建离线应用. A ...
- C和C++中文件读写的区别
C中采用的主要是文件指针的办法,C++中对文件的操作主要运用了“文件流”(即非标准的输入输出)的思想 eg1": #include<stdio.h> //... FILE* fp ...
- 使用 Bulma
一.起因 最近我在学习 SASS,通过它,可以将 CSS 像编程语言一样书写. 在最近之前,我又学习了 Flex 布局,用起来很方便. 所以,我学习了 Bulma 这个纯 CSS 框架--使用 Fle ...
- 查看Linux各发行版本方法
SUSE: cat /etc/SuSE-release Slackware: cat /etc/slackware-version Redhat: cat /etc/redhat-releas ...
- 解决ScrollView嵌套viewpager滑动事件冲突问题
重写ScrollView 第一种方案能解决viewpager的滑动问题,但是scrollView有时会滑不动 public class VerticalScrollView extends Scrol ...
- Android - AndroidStudio 的熟悉
开发环境 * JDK * SDK * AndroidStudio * Genimotioin HelloWorld [ 第一个Android项目建立 ] * 创建项目 [ 项目相关目录 ] Hell ...
- java volatile 关键字(转)
volatile这个关键字可能很多朋友都听说过,或许也都用过.在Java 5之前,它是一个备受争议的关键字,因为在程序中使用它往往会导致出人意料的结果.在Java 5之后,volatile关键字才得以 ...
- ajaxs
AJAX 是一种独立于 Web 服务器软件的浏览器技术.AJAX 基于下列 Web 标准:JavaScript XML HTML CSS 在 AJAX 中使用的 Web 标准已被良好定义,并被所有的主 ...
- 【BZOJ 2120】【国家集训队 2011】【数颜色】(莫队)
题目描述 墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会向你发布如下指令: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔. 2 ...
- foreach循环遍历 行合并
<%@ page contentType="text/html;charset=UTF-8" %> <%@ include file="/WEB-INF ...