Skip to content

Commit cbd2caa

Browse files
committed
minor pr fixes
1 parent 14a41d0 commit cbd2caa

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

explanations/3705/en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ We create a CTE (Common Table Expression) to calculate customer statistics.
4646
**2.3 Trace Walkthrough:**
4747

4848
| Customer | total_orders | peak_hour_orders | rated_orders | avg_rating | Meets criteria? |
49-
|----------|--------------|------------------|--------------|------------|-----------------|
49+
| -------- | ------------ | ---------------- | ------------ | ---------- | --------------- |
5050
| 101 | 4 | 4 | 3 | 4.67 | Yes (all 4) |
5151
| 102 | 3 | 2 | 2 | 3.5 | No (rating < 4) |
5252
| 103 | 3 | 3 | 3 | 4.67 | Yes (all 4) |

explanations/3720/en.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ We call `backtrack([], cnt, False)` to start building the permutation.
4747

4848
**2.3 Trace Walkthrough:**
4949

50-
| Step | pos | char tried | big | path | Action |
51-
| ---- | --- | ---------- | ----- | ------------- | ------------------------- |
52-
| 1 | 0 | 'a' | False | - | Skip (a < 'b') |
53-
| 2 | 0 | 'b' | False | ['b'] | Continue (b == 'b') |
54-
| 3 | 1 | 'a' | False | - | Skip (a < 'b') |
55-
| 4 | 1 | 'b' | False | - | Skip (count=0, no more b) |
50+
| Step | pos | char tried | big | path | Action |
51+
| ---- | --- | ---------- | ----- | ------------- | ---------------------------- |
52+
| 1 | 0 | 'a' | False | - | Skip (a < 'b') |
53+
| 2 | 0 | 'b' | False | ['b'] | Continue (b == 'b') |
54+
| 3 | 1 | 'a' | False | - | Skip (a < 'b') |
55+
| 4 | 1 | 'b' | False | - | Skip (count=0, no more b) |
5656
| 5 | 1 | 'c' | True | ['b','c'] | Continue (c > 'b'), big=True |
57-
| 6 | 2 | 'a' | True | ['b','c','a'] | Found! Return "bca" |
57+
| 6 | 2 | 'a' | True | ['b','c','a'] | Found! Return "bca" |
5858

5959
At step 6, we find that "bca" > "bba", so we return it.
6060

explanations/3724/en.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ We try each possible position j to append.
4747

4848
**2.3 Trace Walkthrough:**
4949

50-
| Step | j | nums1[j] | nums2[j] | last_target | current | median | adjust_cost | total | res |
51-
| ---- | --- | -------- | -------- | ----------- | ------- | ------ | ----------- | ----- | --- |
52-
| 1 | 0 | 2 | 1 | 3 | 2-1=1 | 2 | abs(2-2)+abs(1-2)+abs(3-2)=2 | 1+2+1=4 | 4 |
53-
| 2 | 1 | 8 | 7 | 3 | 2-1=1 | 7 | abs(8-7)+abs(7-7)+abs(3-7)=8 | 1+8+1=10 | 4 |
50+
| Step | j | nums1[j] | nums2[j] | last_target | current | median | adjust_cost | total | res |
51+
| ---- | --- | -------- | -------- | ----------- | ------- | ------ | ---------------------------- | -------- | --- |
52+
| 1 | 0 | 2 | 1 | 3 | 2-1=1 | 2 | abs(2-2)+abs(1-2)+abs(3-2)=2 | 1+2+1=4 | 4 |
53+
| 2 | 1 | 8 | 7 | 3 | 2-1=1 | 7 | abs(8-7)+abs(7-7)+abs(3-7)=8 | 1+8+1=10 | 4 |
5454

5555
At step 1, we find the optimal cost is 4: adjust 2 to 2 (median), then adjust to 1 at position 0 and 3 at the end.
5656

explanations/3728/en.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ We iterate through each position r from 0 to n-1, processing it as a potential r
4747

4848
**2.3 Trace Walkthrough:**
4949

50-
| Step | r | capacity[r] | Add to map? | required_prefix | Check map | res |
51-
| ---- | --- | ----------- | ----------- | ---------------- | --------- | --- |
52-
| 0 | 0 | 9 | No (r < 2) | - | - | 0 |
53-
| 1 | 1 | 3 | No (r < 2) | - | - | 0 |
54-
| 2 | 2 | 3 | Yes (l=0) | prefix[2]-3=12-3=9 | (3, 9)? | 0 |
55-
| 3 | 3 | 3 | Yes (l=1) | prefix[3]-3=15-3=12 | (3, 12)? | 1 |
56-
| 4 | 4 | 9 | Yes (l=2) | prefix[4]-9=18-9=9 | (9, 9)? | 2 |
50+
| Step | r | capacity[r] | Add to map? | required_prefix | Check map | res |
51+
| ---- | --- | ----------- | ----------- | ------------------- | --------- | --- |
52+
| 0 | 0 | 9 | No (r < 2) | - | - | 0 |
53+
| 1 | 1 | 3 | No (r < 2) | - | - | 0 |
54+
| 2 | 2 | 3 | Yes (l=0) | prefix[2]-3=12-3=9 | (3, 9)? | 0 |
55+
| 3 | 3 | 3 | Yes (l=1) | prefix[3]-3=15-3=12 | (3, 12)? | 1 |
56+
| 4 | 4 | 9 | Yes (l=2) | prefix[4]-9=18-9=9 | (9, 9)? | 2 |
5757

5858
At step 3, we find that capacity[1] = 3 and prefix[2] = 12, which matches (3, 12). The subarray [1, 3] = [3, 3, 3] is stable: 3 == 3 and 3 == 3 (sum of middle elements).
5959

solutions/3705/01.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,44 @@
55
SQL Solution:
66
77
WITH customer_stats AS (
8-
SELECT
8+
SELECT
99
customer_id,
1010
COUNT(*) AS total_orders,
1111
SUM(
12-
CASE
12+
CASE
1313
WHEN TIME(order_timestamp) BETWEEN '11:00:00' AND '14:00:00'
1414
OR TIME(order_timestamp) BETWEEN '18:00:00' AND '21:00:00'
15-
THEN 1
16-
ELSE 0
15+
THEN 1
16+
ELSE 0
1717
END
1818
) AS peak_hour_orders,
1919
COUNT(order_rating) AS rated_orders,
2020
AVG(order_rating) AS avg_rating
21-
FROM
21+
FROM
2222
restaurant_orders
23-
GROUP BY
23+
GROUP BY
2424
customer_id
25-
HAVING
25+
HAVING
2626
COUNT(*) >= 3
2727
AND SUM(
28-
CASE
28+
CASE
2929
WHEN TIME(order_timestamp) BETWEEN '11:00:00' AND '14:00:00'
3030
OR TIME(order_timestamp) BETWEEN '18:00:00' AND '21:00:00'
31-
THEN 1
32-
ELSE 0
31+
THEN 1
32+
ELSE 0
3333
END
3434
) * 100.0 / COUNT(*) >= 60.0
3535
AND AVG(order_rating) >= 4.0
3636
AND COUNT(order_rating) * 100.0 / COUNT(*) >= 50.0
3737
)
38-
SELECT
38+
SELECT
3939
customer_id,
4040
total_orders,
4141
ROUND(peak_hour_orders * 100.0 / total_orders, 0) AS peak_hour_percentage,
4242
ROUND(avg_rating, 2) AS average_rating
43-
FROM
43+
FROM
4444
customer_stats
45-
ORDER BY
45+
ORDER BY
4646
average_rating DESC,
4747
customer_id DESC;
4848
"""

0 commit comments

Comments
 (0)