
LeetCode
WjXIIIIIIIIII
这个作者很懒,什么都没留下…
展开
-
LeetCode178. 分数排名
分数排名# Write your MySQL query statement belowselect s1.Score, count(distinct(s2.Score)) Rankfrom Scores s1, Scores s2where s1.Score<=s2.Scoregroup by s1.Idorder by Rank;原创 2019-10-16 20:07:22 · 295 阅读 · 0 评论 -
leetcode 177. 第N高的薪水
编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。±—±-------+| Id | Salary |±—±-------+| 1 | 100 || 2 | 200 || 3 | 300 |±—±-------+例如上述 Employee 表,n = 2 时,应返回第二高的薪水 200。如果不存在第 n 高的薪水,那么查询...原创 2019-10-16 11:39:10 · 259 阅读 · 0 评论 -
leetcode 1179
部门表 Department:±--------------±--------+| Column Name | Type |±--------------±--------+| id | int || revenue | int || month | varchar |±--------------±----...原创 2019-10-16 11:29:28 · 375 阅读 · 0 评论 -
leetcode 627
给定一个 salary 表,如下所示,有 m = 男性 和 f = 女性 的值。交换所有的 f 和 m 值(例如,将所有 f 值更改为 m,反之亦然)。要求只使用一个更新(Update)语句,并且没有中间的临时表。注意,您必只能写一个 Update 语句,请不要编写任何 Select 语句。例如:idnamesexsalary1Am25002Bf15...原创 2019-10-16 11:24:15 · 218 阅读 · 0 评论 -
Leetcode 620
某城市开了一家新的电影院,吸引了很多人过来看电影。该电影院特别注意用户体验,专门有个 LED显示板做电影推荐,上面公布着影评和相关电影描述。作为该电影院的信息部主管,您需要编写一个 SQL查询,找出所有影片描述为非 boring (不无聊) 的并且 id 为奇数 的影片,结果请按等级 rating 排列。例如,下表 cinema:±--------±----------±----------...原创 2019-10-16 11:20:16 · 223 阅读 · 0 评论 -
LeetCode 2.两数相加
给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字 0 之外,这两个数都不会以 0 开头。示例:输入:(2 -> 4 -> 3) + (5 -> ...原创 2019-09-06 16:44:46 · 203 阅读 · 0 评论 -
LeetCode 9.回文素数
判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。示例 1:输入: 121输出: true示例 2:输入: -121输出: false解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。示例 3:输入: 10输出: false解释: 从右向左读, 为 01 。因此它不是一个回文数。来源:力扣(Le...原创 2019-09-06 15:58:19 · 244 阅读 · 0 评论 -
LeetCode 19. 删除链表的倒数第N个节点
给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。示例:给定一个链表: 1->2->3->4->5, 和 n = 2.当删除了倒数第二个节点后,链表变为 1->2->3->5.说明:给定的 n 保证是有效的。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/remove-nt...原创 2019-09-06 11:44:38 · 182 阅读 · 0 评论 -
LeetCode 28.strStr()
实现 strStr() 函数。给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。示例 1:输入: haystack = “hello”, needle = “ll”输出: 2示例 2:输入: haystack = “aaaaa”, needle = “bba...原创 2019-09-06 10:41:12 · 152 阅读 · 0 评论 -
LeetCode 27.移除元素
给定一个数组 nums 和一个值 val,你需要原地移除所有数值等于 val 的元素,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:给定 nums = [3,2,2,3], val = 3,函数应该返回新的长度 2, 并且 nums 中的前两个元素均为...原创 2019-09-06 10:32:17 · 142 阅读 · 0 评论 -
LeetCode 26. 删除排序数组中的重复项
给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。示例 1:给定数组 nums = [1,1,2],函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。你不需要考虑数组中超出新长度后面的元素。示例 2:给定 nums ...原创 2019-09-05 20:56:57 · 147 阅读 · 0 评论 -
LeetCode 20. 有效的括号
class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ count = 500 while count > 0: if '()' in s: ...原创 2019-09-05 20:36:15 · 200 阅读 · 0 评论 -
LeetCode 1114.按序打印
import Queueclass Foo(object): def __init__(self): self.q2 = Queue.Queue() self.q3 = Queue.Queue() def first(self, printFirst): """ :type printFirst: method...原创 2019-09-05 16:15:02 · 439 阅读 · 0 评论 -
LeetCode 35. 搜索插入位置
class Solution(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if target in nums: ...原创 2019-09-05 15:42:45 · 141 阅读 · 0 评论 -
LeetCode 21.合并两个有序链表
# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def mergeTwoLists(self, l1, l...原创 2019-09-05 15:13:06 · 147 阅读 · 0 评论 -
Leetcode 1.两数之和
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ rst = [] count = 0...原创 2019-09-05 14:53:58 · 143 阅读 · 0 评论 -
Leetcode 7. 整数反转
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x >= 0: tmp = int(str(x)[::-1]) return tmp if -...原创 2019-09-05 14:51:59 · 152 阅读 · 0 评论