Skip to content

Commit cd5befe

Browse files
committed
feat(leetcode): new solutions
1 parent befd50f commit cd5befe

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
WITH ranked AS (
2+
SELECT
3+
d.name AS "Department",
4+
e.name AS "Employee",
5+
e.salary AS "Salary",
6+
DENSE_RANK() OVER (
7+
PARTITION BY e.departmentId
8+
ORDER BY e.salary DESC
9+
) AS rn
10+
FROM Employee e
11+
JOIN Department d ON d.id = e.departmentId
12+
)
13+
SELECT "Department","Employee","Salary"
14+
FROM ranked
15+
WHERE rn <= 3
16+
ORDER BY "Department"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DELETE FROM Person p1 USING Person p2
2+
WHERE p1.id > p2.id AND p1.email = p2.email;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def reverse(self, x: int) -> int:
3+
MAX_32 = 2 ** 31 - 1
4+
5+
sign = [1, -1][x < 0]
6+
y, x = 0, abs(x)
7+
while x > 0:
8+
y *= 10
9+
y += x % 10
10+
if y > MAX_32:
11+
return 0
12+
x //= 10
13+
14+
return y * sign

0 commit comments

Comments
 (0)