Ruizhi Ma's Blog

Keep Calm and Carry On

Problem 176

Second Highest Salary

问题描述 https://leetcode.com/problems/second-highest-salary/ 解决思路 先找到最高的,再找到比最高的低的,就是第二高的Salary了 代码 # Write your MySQL query statement below Select max(Salary) as SecondHighestSalary From Employee W...

Problem 168

Excel Sheet Column Title

问题描述 Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ... Example 1:...

Problem 197

Rising Temperature

问题描述 https://leetcode.com/problems/rising-temperature/ 代码 # Write your MySQL query statement below SELECT tb1.Id FROM Weather as tb1 INNER JOIN Weather as tb2 ON tb1.Temperature > tb2.Temperatu...

Problem 155

Min Stack

问题描述 看链接:https://leetcode.com/problems/min-stack/ 解决思路 MinStack,就是创建另一个stack2,用来和push进stack1的元素比较,更小的一个,放入stack2,这样总能保证stack2的栈顶元素,是最小的 代码 package leetcode; import com.sun.corba.se.impl.orbutil....

Problem 181

Employee earning more than their manager

问题描述 https://leetcode.com/problems/employees-earning-more-than-their-managers/ 代码 # Write your MySQL query statement below SELECT tb1.Name as Employee FROM Employee as tb1 LEFT JOIN Employee as tb...

Problem 175

Combine two tables

问题描述 https://leetcode.com/problems/combine-two-tables/ 解决思路 用left join的方式,以tb1.PersonID = tb2.PersonID为条件,将两表join到一起,并且select出特定的行即可。 代码 # Write your MySQL query statement below SELECT tb1.FirstN...

Problem 160

Intersection of Two Linked Lists

问题描述 https://leetcode.com/problems/intersection-of-two-linked-lists/ 解决思路 身体不舒服,明天来补 问题解惑 代码 package leetcode; public class IntersectionofTwoLinkedLists { public class ListNode { int ...

Problem 69

Sqrt(x)

问题描述 Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated ...

TreeMap

TreeMap的使用和底层实现_Comparable接口

TreeMap类 package cn.sxt.collection; import java.util.Map; import java.util.TreeMap; /** * 测试TreeMap的使用 * @author Administrator * */ public class TestTreeMap { public static void main(String...

Problem 141

Linked List Cycle

问题描述 见链接:https://leetcode.com/problems/linked-list-cycle/ 解决思路 用两个快慢指针,快指针走到null就没有环,快指正走一次,慢指针走一次,相遇则有环。 问题解惑 好像在fast和slow走的地方有点模糊,因为slow和fast一起走,如果slow.next走过了fast.next城环的地方又当如何呢?(待解决) 代码 pack...