
【956】LeetCode
LGX_TvT
小步快跑
展开
-
175. Combine Two Tables
Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+PersonI原创 2018-01-14 22:27:16 · 1379 阅读 · 0 评论 -
35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Examp原创 2018-01-28 00:28:57 · 1234 阅读 · 0 评论 -
66. Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are st转载 2018-02-05 01:20:45 · 1164 阅读 · 0 评论 -
67. Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".解题思路:直接按位相加,最后判断最后一位是否有进位class Solution { public String addBinary(String a, String b) {转载 2018-02-10 01:06:41 · 1155 阅读 · 0 评论 -
69. Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation: The square root of 8转载 2018-02-10 01:52:49 · 1233 阅读 · 0 评论 -
70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive inte原创 2018-02-11 01:05:57 · 1037 阅读 · 0 评论 -
38. Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as “one 1” or 11. 11 is read off as “t转载 2018-01-30 14:29:48 · 1353 阅读 · 0 评论 -
112. Path Sum
112. Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree转载 2018-03-07 01:20:35 · 738 阅读 · 0 评论 -
620. Not Boring Movies
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies w原创 2018-01-24 18:43:29 · 1284 阅读 · 0 评论 -
100. Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:Inp转载 2018-03-08 20:20:56 · 783 阅读 · 0 评论 -
118. Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]第一排第二排固定 第三排[1,2,1],2 = 第二排的1+1 第四排原创 2018-03-11 23:40:59 · 778 阅读 · 0 评论 -
矩阵A乘以B
7-5 矩阵A乘以B给定两个矩阵A和B,要求你计算它们的乘积矩阵AB。需要注意的是,只有规模匹配的矩阵才可以相乘。即若A有Ra行、Ca列,B有Rb行、Cb列,则只有Ca与Rb相等时,两个矩阵才能相乘。输入格式:输入先后给出两个矩阵A和B。对于每个矩阵,首先在一行中给出其行数R和列数C,随后R行,每行给出C个整数,以1个空格分隔,且行首尾没有多余...原创 2017-11-15 11:41:17 · 12502 阅读 · 0 评论 -
28. Implement strStr()
Implement strStr()Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output:原创 2018-01-28 00:08:01 · 1282 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place w原创 2018-01-27 23:48:36 · 1250 阅读 · 0 评论 -
176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For example, gi原创 2018-01-15 16:17:20 · 1415 阅读 · 0 评论 -
181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary | Mana原创 2018-01-15 16:35:27 · 1392 阅读 · 0 评论 -
182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For example,原创 2018-01-15 16:55:23 · 2587 阅读 · 0 评论 -
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.Table: Customers.+----+-------+| Id | Name |+--原创 2018-01-24 17:36:45 · 1395 阅读 · 0 评论 -
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.+----+------------------+| Id | Email |+----+----------转载 2018-01-24 18:00:23 · 1339 阅读 · 0 评论 -
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.+---------+------------+------------------+| Id(INT) | Date(DATE) |原创 2018-01-24 18:13:51 · 1324 阅读 · 0 评论 -
595. Big Countries
There is a table World+-----------------+------------+------------+--------------+---------------+| name | continent | area | population | gdp |+-----------------+------原创 2018-01-24 18:19:18 · 1357 阅读 · 0 评论 -
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.For example, the table:+---------+------------+| student | class |原创 2018-01-24 18:36:00 · 1324 阅读 · 0 评论 -
627. Swap Salary
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate转载 2018-01-24 18:53:28 · 1297 阅读 · 0 评论 -
9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integ原创 2018-01-25 19:22:01 · 1215 阅读 · 0 评论 -
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ele原创 2018-01-18 13:52:09 · 1569 阅读 · 0 评论 -
删除字符串中的子串
5-29 删除字符串中的子串输入2个字符串S1和S2,要求删除字符串S1中出现的所有子串S2,即结果字符串中不能包含S2。输入格式:输入在2行中分别给出不超过80个字符长度的、以回车结束的2个非空字符串,对应S1和S2。输出格式:在一行中输出删除字符串S1中出现的所有子串S2后的结果字符串。输入样例:Tomcat is a male ccatatcat输出...转载 2017-11-15 11:16:55 · 1752 阅读 · 0 评论