![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
flyersong_bupt
这个作者很懒,什么都没留下…
展开
-
【LeetCode】69、int sqrt(int x).
1、此题应该利用binary search 的方法class Solution(object): def mySqrt(self, x): """ :type x: int :rtype: int """ l,r = 0,x mid = (1+x)/2 while l<=r:转载 2017-08-29 18:09:54 · 202 阅读 · 0 评论 -
【LeetCode】125、Valid Palindrome
1、题目描述:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example:”A man, a plan, a canal: Panama” is a palindrome.”race a car” is转载 2017-09-12 20:17:59 · 181 阅读 · 0 评论 -
【LeetCode】596、Classes More Than 5 Students
题目要求:There is a table courses with columns: student and classPlease list out all classes which have more than or equal to 5 students.解答:COUNT与 DISTINCT组合使用,满足The students should not be count转载 2017-09-28 15:13:52 · 887 阅读 · 0 评论 -
【LeetCode】627、Swap Salary
解答:1)使用IF UPDATE Salary SET sex = IF(sex='m','f','m')或者使用 CASE WHEN... THEN ...ELSE...END要注意语法问题UPDATE Salary SET sex = (CASE WHEN sex='m' THEN 'f' ELSE 'm' END)转载 2017-09-28 16:47:01 · 284 阅读 · 0 评论 -
【LeetCode】234、Palindrome Linked List
1、题目要求:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?2、转载 2017-09-13 16:24:39 · 132 阅读 · 0 评论 -
【LeetCode】175、combine two tables ; 176. Second Highest Salary
1、题目要求(175、combine two tables):Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those peopl转载 2017-09-21 19:29:37 · 226 阅读 · 0 评论 -
【LeetCode】181. Employees Earning More Than Their Managers
1、题目要求:Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.转载 2017-09-23 19:27:26 · 162 阅读 · 0 评论 -
【LeetCode】182. Duplicate Emails
题目要求:Write a SQL query to find all duplicate emails in a table named Person.解答:比较顺的思路就是用GROUP BY、HAVING ;但是还可以用DISTINCT 联表查询的方法。1) SELECT Email FROM PersonGROUP BY Email HAVING COUNT(*) >= 22) 摘转载 2017-09-26 22:17:24 · 191 阅读 · 0 评论 -
【LeetCode】183、Customers Who Never Order
题目要求:Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.解答:1) LEFT JOIN 左联结:SELECT Name AS Custo转载 2017-09-27 21:22:13 · 189 阅读 · 0 评论 -
【LeetCode】196. Delete Duplicate Emails
题目要求:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.解答:# Write your MySQL query statement belowDELETE p1转载 2017-09-28 10:07:15 · 226 阅读 · 0 评论 -
【LeetCode】197、Rising Temperature
题目要求:Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.解答:关于时间的Mysql的函数:1、TO_DAYS(date):给定一个日期data,返回从年份0开始的天数2转载 2017-09-28 10:39:47 · 265 阅读 · 0 评论 -
【LeetCode】55、jump game
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determin转载 2017-09-08 19:22:24 · 142 阅读 · 0 评论 -
【LeetCode】50、pow(x,n)
1、http://blog.csdn.net/nerv3x3/article/details/3465663转载 2017-08-29 11:25:13 · 217 阅读 · 0 评论 -
【LeetCode】9、Palindrome Number
1、题目要求:Determine whether an integer is a palindrome. Do this without extra space.2、如果将数字转化为字符串,就创建了一个新的变量,会占用新的空间。这样子做的代码如下:class Solution(object): def isPalindrome(self, x): """转载 2017-09-13 11:45:04 · 152 阅读 · 0 评论