Skip to content

Commit bc6fefa

Browse files
committed
feat: add solutions to lc problems: No.0586,0806,1741,1890
- No.0586.Customer Placing the Largest Number of Orders - No.0806.Number of Lines To Write String - No.1741.Find Total Time Spent by Each Employee - No.1890.The Latest Login in 2020
1 parent 7d672de commit bc6fefa

File tree

11 files changed

+80
-9
lines changed

11 files changed

+80
-9
lines changed

solution/0500-0599/0586.Customer Placing the Largest Number of Orders/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ ORDER BY COUNT(customer_number) DESC
7575
LIMIT 1;
7676
```
7777

78+
SQL Server
79+
80+
```sql
81+
SELECT TOP 1
82+
customer_number
83+
FROM
84+
orders
85+
GROUP BY customer_number
86+
ORDER BY COUNT(customer_number) DESC;
87+
```
88+
7889
<!-- tabs:end -->

solution/0500-0599/0586.Customer Placing the Largest Number of Orders/README_EN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,15 @@ ORDER BY COUNT(customer_number) DESC
6969
LIMIT 1;
7070
```
7171

72+
SQL Server
73+
74+
```sql
75+
SELECT TOP 1
76+
customer_number
77+
FROM
78+
orders
79+
GROUP BY customer_number
80+
ORDER BY COUNT(customer_number) DESC;
81+
```
82+
7283
<!-- tabs:end -->

solution/0800-0899/0806.Number of Lines To Write String/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ func numberOfLines(widths []int, s string) []int {
136136
}
137137
```
138138

139+
### **Rust**
140+
141+
```rust
142+
impl Solution {
143+
pub fn number_of_lines(widths: Vec<i32>, s: String) -> Vec<i32> {
144+
let mut count = 1;
145+
let mut sum = 0;
146+
for c in s.as_bytes() {
147+
let width = widths[(c - b'a') as usize];
148+
if sum + width > 100 {
149+
sum = 0;
150+
count += 1;
151+
}
152+
sum += width;
153+
}
154+
vec![count, sum]
155+
}
156+
}
157+
```
158+
139159
### **...**
140160

141161
```

solution/0800-0899/0806.Number of Lines To Write String/README_EN.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ func numberOfLines(widths []int, s string) []int {
131131
}
132132
```
133133

134+
### **Rust**
135+
136+
```rust
137+
impl Solution {
138+
pub fn number_of_lines(widths: Vec<i32>, s: String) -> Vec<i32> {
139+
let mut count = 1;
140+
let mut sum = 0;
141+
for c in s.as_bytes() {
142+
let width = widths[(c - b'a') as usize];
143+
if sum + width > 100 {
144+
sum = 0;
145+
count += 1;
146+
}
147+
sum += width;
148+
}
149+
vec![count, sum]
150+
}
151+
}
152+
```
153+
134154
### **...**
135155

136156
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
impl Solution {
2+
pub fn number_of_lines(widths: Vec<i32>, s: String) -> Vec<i32> {
3+
let mut count = 1;
4+
let mut sum = 0;
5+
for c in s.as_bytes() {
6+
let width = widths[(c - b'a') as usize];
7+
if sum + width > 100 {
8+
sum = 0;
9+
count += 1;
10+
}
11+
sum += width;
12+
}
13+
vec![count, sum]
14+
}
15+
}

solution/1700-1799/1741.Find Total Time Spent by Each Employee/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ Result table:
6262
### **SQL**
6363

6464
```sql
65-
# Write your MySQL query statement below
6665
SELECT
6766
event_day AS day,
6867
emp_id,

solution/1700-1799/1741.Find Total Time Spent by Each Employee/README_EN.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ Employee 2 has two events: one on day 2020-11-28 with a total of (33 - 3) = 30,
6666
### **SQL**
6767

6868
```sql
69-
# Write your MySQL query statement below
7069
SELECT
7170
event_day AS day,
7271
emp_id,

solution/1700-1799/1741.Find Total Time Spent by Each Employee/Solution.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Write your MySQL query statement below
21
SELECT
32
event_day AS day,
43
emp_id,

solution/1800-1899/1890.The Latest Login in 2020/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ Result 表:
6464
<!-- 这里可写当前语言的特殊实现逻辑 -->
6565

6666
```sql
67-
# Write your MySQL query statement below
6867
SELECT
6968
user_id,
70-
max(time_stamp) AS last_stamp
69+
MAX(time_stamp) AS last_stamp
7170
FROM
7271
Logins
7372
WHERE YEAR(time_stamp) = 2020

solution/1800-1899/1890.The Latest Login in 2020/README_EN.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ User 14 did not login in 2020, so we do not include them in the result table.
6666
### **SQL**
6767

6868
```sql
69-
# Write your MySQL query statement below
7069
SELECT
7170
user_id,
72-
max(time_stamp) AS last_stamp
71+
MAX(time_stamp) AS last_stamp
7372
FROM
7473
Logins
7574
WHERE YEAR(time_stamp) = 2020

0 commit comments

Comments
 (0)