
LeetCode
Zachos
这个作者很懒,什么都没留下…
展开
-
Leetcode-MySQL(180. 连续出现的数字)
编写一个 SQL 查询,查找所有至少连续出现三次的数字。 # Write your MySQL query statement below SELECT distinct a1.Num as ConsecutiveNums from Logs a1,logs b1, logs c1 where a1.Id = b1.Id-1 and c1.Id = b1.Id+1 and a1.Num = b1.Num and b1.Num = c1.Num 点击链接 ...原创 2020-10-09 22:40:10 · 132 阅读 · 0 评论 -
Leetcode-MySQL(183. 从不订购的客户)
从不订购的客户:某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。 # Write your MySQL query statement below SELECT Customers.Name as Customers FROM Customers LEFT JOIN orders on Customers.Id <=> orders.CustomerId WHERE orders.CustomerId IS NULL;.原创 2020-10-09 22:37:04 · 151 阅读 · 0 评论 -
Leetcode-MySQL(175. 组合两个表)
组合两个表 # Write your MySQL query statement below SELECT FirstName, LastName, City, State FROM Person LEFT JOIN Address ON Person.PersonId = Address.PersonId原创 2020-10-09 22:35:51 · 102 阅读 · 0 评论 -
LeetCode_Day9
121.买卖股票的最佳价格 解题思路:用一个变量记下历史最低价格 minprice,在第 i 天卖出股票能得到的利润就是 prices[i] - minprice。遍历价格数组一遍,记录历史最低点,然后用prices[i] - minprice即可得到。 class Solution: def maxProfit(self, prices: List[int]) -> int: minprice = float('inf') maxprofit = 0原创 2020-06-07 16:58:34 · 277 阅读 · 0 评论 -
LeetCode_Day8
69.X的平方根:实现 int sqrt(int x) 函数。计算并返回 x 的平方根,其中 x 是非负整数。由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 解题思路:本题是一道常见的面试题,面试官一般会要求面试者在不使用x\sqrt{x}x函数的情况下,得到x的平方根的整数部分。一般的思路会有以下几种: 通过其它的数学函数代替平方根函数得到精确结果,取整数部分作为答案; 通过数学方法得到近似结果,直接作为答案。 「袖珍计算器算法」是一种用指数函数 expexpexp和对数函数 lnln原创 2020-06-07 15:02:56 · 164 阅读 · 0 评论 -
LeetCode_Day7
66.给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/plus-one class Solution: def plusOne(self, digits: List[int]) -> List[int]: for i in range(1,len原创 2020-06-05 11:48:36 · 152 阅读 · 0 评论