Skip to content

Commit

Permalink
modified leetcode posts for terminal shortcode hugo
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirPaulb committed Feb 8, 2024
1 parent c06b270 commit 7a589a0
Show file tree
Hide file tree
Showing 411 changed files with 169 additions and 482 deletions.
2 changes: 1 addition & 1 deletion content/posts/leetcode/0007-reverse-integer.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int reverse(int x) {
int ans = 0;
for (; x != 0; x /= 10) {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0041-first-missing-positive.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int firstMissingPositive(int* nums, int numsSize) {

int Max = nums[0], i, *Count;
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0045-jump-game-ii.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
#define min(a, b) a < b ? a : b
int jump(int* nums, int numsSize) {
int dp[numsSize];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ var maxDepth = function (root) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
/**
* Definition for a binary tree node.
* struct TreeNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ var sortedListToBST = function (head) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
/**
* Definition for singly-linked list.
* struct ListNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ var minDepth = function (root) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
/**
* Definition for a binary tree node.
* struct TreeNode {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0129-sum-root-to-leaf-numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ var sumNumbers = function (root) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
/**
* Definition for a binary tree node.
* struct TreeNode {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0136-single-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int singleNumber(int* nums, int numsSize) {
int ans = 0;
for (int i = 0; i < numsSize; i++) {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0137-single-number-ii.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ impl Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int singleNumber(int* nums, int numsSize) {
int ans = 0;
for (int i = 0; i < 32; i++) {
Expand Down
1 change: 0 additions & 1 deletion content/posts/leetcode/0175-combine-two-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def combine_two_tables(person: pd.DataFrame, address: pd.DataFrame) -> pd.DataFr
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT firstName, lastName, city, state
FROM
Expand Down
3 changes: 0 additions & 3 deletions content/posts/leetcode/0176-second-highest-salary.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def second_highest_salary(employee: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT
(
Expand All @@ -128,7 +127,6 @@ SELECT
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
Expand All @@ -143,7 +141,6 @@ WHERE salary < (SELECT MAX(salary) FROM Employee);
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
WITH T AS (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rk FROM Employee)
SELECT (SELECT DISTINCT salary FROM T WHERE rk = 2) AS SecondHighestSalary;
Expand Down
1 change: 0 additions & 1 deletion content/posts/leetcode/0177-nth-highest-salary.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def nth_highest_salary(employee: pd.DataFrame, N: int) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
SET N = N - 1;
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0178-rank-scores.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def order_scores(scores: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT
score,
Expand All @@ -114,7 +113,6 @@ FROM Scores;
<!-- tabs:start -->

```sql
{{< /terminal >}}
SELECT
Score,
CONVERT(rk, SIGNED) `Rank`
Expand Down
3 changes: 0 additions & 3 deletions content/posts/leetcode/0180-consecutive-numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def consecutive_numbers(logs: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT DISTINCT l2.num AS ConsecutiveNums
FROM
Expand All @@ -116,7 +115,6 @@ We can also group the numbers by using the `IF` function to determine whether th
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
WITH
T AS (
Expand All @@ -139,7 +137,6 @@ WHERE a = num AND b = num;
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
WITH
T AS (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def find_employees(employee: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
SELECT Name AS Employee
FROM Employee AS Curr
WHERE
Expand All @@ -104,7 +103,6 @@ WHERE
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT
e1.name AS Employee
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0182-duplicate-emails.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def duplicate_emails(person: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT email
FROM Person
Expand All @@ -103,7 +102,6 @@ We can use a self-join to join the `Person` table with itself, and then filter o
<!-- tabs:start -->

```sql
{{< /terminal >}}
SELECT DISTINCT p1.email
FROM
person AS p1,
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0183-customers-who-never-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def find_customers(customers: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFram
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT name AS Customers
FROM Customers
Expand All @@ -132,7 +131,6 @@ Use `LEFT JOIN` to join the tables and return the data where `CustomerId` is `NU
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT name AS Customers
FROM
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0184-department-highest-salary.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ We can use an equi-join to join the `Employee` table and the `Department` table
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT d.name AS department, e.name AS employee, salary
FROM
Expand All @@ -124,7 +123,6 @@ We can use an equi-join to join the `Employee` table and the `Department` table
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
WITH
T AS (
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0185-department-top-three-salaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def top_three_salaries(
{{< /terminal >}}

```sql
{{< /terminal >}}
SELECT
Department.NAME AS Department,
Employee.NAME AS Employee,
Expand All @@ -165,7 +164,6 @@ WHERE
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
WITH
T AS (
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0191-number-of-1-bits.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ var hammingWeight = function (n) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int hammingWeight(uint32_t n) {
int ans = 0;
while (n) {
Expand Down
3 changes: 0 additions & 3 deletions content/posts/leetcode/0196-delete-duplicate-emails.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def delete_duplicate_emails(person: pd.DataFrame) -> None:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
DELETE FROM Person
WHERE id NOT IN (SELECT MIN(id) FROM (SELECT * FROM Person) AS p GROUP BY email);
Expand All @@ -102,7 +101,6 @@ WHERE id NOT IN (SELECT MIN(id) FROM (SELECT * FROM Person) AS p GROUP BY email)
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
DELETE FROM Person
WHERE
Expand Down Expand Up @@ -130,7 +128,6 @@ WHERE
<!-- tabs:start -->

```sql
{{< /terminal >}}
DELETE p2
FROM
person AS p1
Expand Down
2 changes: 0 additions & 2 deletions content/posts/leetcode/0197-rising-temperature.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def rising_temperature(weather: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT w1.id
FROM
Expand All @@ -106,7 +105,6 @@ FROM
<!-- tabs:start -->

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT w1.id
FROM
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0202-happy-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ impl Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int getNext(int n) {
int res = 0;
while (n) {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0217-contains-duplicate.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int cmp(const void* a, const void* b) {
return *(int*) a - *(int*) b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
/**
* Definition for singly-linked list.
* struct ListNode {
Expand Down
4 changes: 2 additions & 2 deletions content/posts/leetcode/0242-valid-anagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public class Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int cmp(const void* a, const void* b) {
return *(char*) a - *(char*) b;
}
Expand Down Expand Up @@ -265,8 +265,8 @@ impl Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
bool isAnagram(char* s, char* t) {
int n = strlen(s);
int m = strlen(t);
Expand Down
1 change: 0 additions & 1 deletion content/posts/leetcode/0262-trips-and-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def trips_and_users(trips: pd.DataFrame, users: pd.DataFrame) -> pd.DataFrame:
{{< /terminal >}}

```sql
{{< /terminal >}}
# Write your MySQL query statement below
SELECT
request_at AS Day,
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0283-move-zeroes.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ var moveZeroes = function (nums) {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
void moveZeroes(int* nums, int numsSize) {
int i = 0;
for (int j = 0; j < numsSize; j++) {
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0303-range-sum-query---immutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ class NumArray {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
typedef struct {
int* s;
} NumArray;
Expand Down
2 changes: 1 addition & 1 deletion content/posts/leetcode/0343-integer-break.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ impl Solution {
```
{{< /terminal >}}

{{< terminal title="C Code" >}}
```c
{{< /terminal >}}
int integerBreak(int n) {
if (n < 4) {
return n - 1;
Expand Down
1 change: 0 additions & 1 deletion content/posts/leetcode/0367-valid-perfect-square.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ impl Solution {
This is a math problem:

```bash
{{< /terminal >}}
1 = 1
4 = 1 + 3
9 = 1 + 3 + 5
Expand Down
Loading

0 comments on commit 7a589a0

Please sign in to comment.