Skip to content

Commit b91d683

Browse files
committed
feat: update solutions to lc problems: No.1511,1860
1 parent 9af213f commit b91d683

File tree

8 files changed

+97
-38
lines changed

8 files changed

+97
-38
lines changed

solution/1500-1599/1511.Customer Order Frequency/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,18 @@ Moustafa 在2020年6月花费了$110 (10 * 2 + 45 * 2), 在7月花费了$0.
116116
### **SQL**
117117

118118
```sql
119-
119+
# Write your MySQL query statement below
120+
SELECT
121+
c.customer_id AS CUSTOMER_ID,
122+
c.name AS NAME
123+
FROM
124+
Customers c, Product p, Orders o
125+
WHERE
126+
c.customer_id = o.customer_id
127+
AND p.product_id = o.product_id
128+
GROUP BY c.customer_id
129+
HAVING sum(if(month(o.order_date)=6, price*quantity, 0)) >= 100
130+
AND sum(if(month(o.order_date)=7, price*quantity, 0)) >= 100;
120131
```
121132

122133
<!-- tabs:end -->

solution/1500-1599/1511.Customer Order Frequency/README_EN.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,18 @@ Moustafa spent $110 (10 * 2 + 45 * 2) in June and $0 in July 2020.
217217
### **SQL**
218218

219219
```sql
220-
220+
# Write your MySQL query statement below
221+
SELECT
222+
c.customer_id AS CUSTOMER_ID,
223+
c.name AS NAME
224+
FROM
225+
Customers c, Product p, Orders o
226+
WHERE
227+
c.customer_id = o.customer_id
228+
AND p.product_id = o.product_id
229+
GROUP BY c.customer_id
230+
HAVING sum(if(month(o.order_date)=6, price*quantity, 0)) >= 100
231+
AND sum(if(month(o.order_date)=7, price*quantity, 0)) >= 100;
221232
```
222233

223234
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
c.customer_id AS CUSTOMER_ID,
4+
c.name AS NAME
5+
FROM
6+
Customers c, Product p, Orders o
7+
WHERE
8+
c.customer_id = o.customer_id
9+
AND p.product_id = o.product_id
10+
GROUP BY c.customer_id
11+
HAVING sum(if(month(o.order_date)=6, price*quantity, 0)) >= 100
12+
AND sum(if(month(o.order_date)=7, price*quantity, 0)) >= 100;

solution/1800-1899/1860.Incremental Memory Leak/README.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,10 @@
5959
class Solution:
6060
def memLeak(self, memory1: int, memory2: int) -> List[int]:
6161
i = 1
62-
while 1:
62+
while memory1 >= i or memory2 >= i:
6363
if memory1 >= memory2:
64-
if memory1 < i:
65-
break
6664
memory1 -= i
6765
else:
68-
if memory2 < i:
69-
break
7066
memory2 -= i
7167
i += 1
7268
return [i, memory1, memory2]
@@ -80,16 +76,10 @@ class Solution:
8076
class Solution {
8177
public int[] memLeak(int memory1, int memory2) {
8278
int i = 1;
83-
while (true) {
79+
while (memory1 >= i || memory2 >= i) {
8480
if (memory1 >= memory2) {
85-
if (memory1 < i) {
86-
break;
87-
}
8881
memory1 -= i;
8982
} else {
90-
if (memory2 < i) {
91-
break;
92-
}
9383
memory2 -= i;
9484
}
9585
++i;
@@ -121,6 +111,26 @@ var memLeak = function(memory1, memory2) {
121111
};
122112
```
123113

114+
### **C++**
115+
116+
```cpp
117+
class Solution {
118+
public:
119+
vector<int> memLeak(int memory1, int memory2) {
120+
int i = 1;
121+
while (memory1 >= i || memory2 >= i) {
122+
if (memory1 >= memory2) {
123+
memory1 -= i;
124+
} else {
125+
memory2 -= i;
126+
}
127+
++i;
128+
}
129+
return {i, memory1, memory2};
130+
}
131+
};
132+
```
133+
124134
### **...**
125135
126136
```

solution/1800-1899/1860.Incremental Memory Leak/README_EN.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@
5353
class Solution:
5454
def memLeak(self, memory1: int, memory2: int) -> List[int]:
5555
i = 1
56-
while 1:
56+
while memory1 >= i or memory2 >= i:
5757
if memory1 >= memory2:
58-
if memory1 < i:
59-
break
6058
memory1 -= i
6159
else:
62-
if memory2 < i:
63-
break
6460
memory2 -= i
6561
i += 1
6662
return [i, memory1, memory2]
@@ -72,16 +68,10 @@ class Solution:
7268
class Solution {
7369
public int[] memLeak(int memory1, int memory2) {
7470
int i = 1;
75-
while (true) {
71+
while (memory1 >= i || memory2 >= i) {
7672
if (memory1 >= memory2) {
77-
if (memory1 < i) {
78-
break;
79-
}
8073
memory1 -= i;
8174
} else {
82-
if (memory2 < i) {
83-
break;
84-
}
8575
memory2 -= i;
8676
}
8777
++i;
@@ -113,6 +103,26 @@ var memLeak = function(memory1, memory2) {
113103
};
114104
```
115105

106+
### **C++**
107+
108+
```cpp
109+
class Solution {
110+
public:
111+
vector<int> memLeak(int memory1, int memory2) {
112+
int i = 1;
113+
while (memory1 >= i || memory2 >= i) {
114+
if (memory1 >= memory2) {
115+
memory1 -= i;
116+
} else {
117+
memory2 -= i;
118+
}
119+
++i;
120+
}
121+
return {i, memory1, memory2};
122+
}
123+
};
124+
```
125+
116126
### **...**
117127
118128
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
vector<int> memLeak(int memory1, int memory2) {
4+
int i = 1;
5+
while (memory1 >= i || memory2 >= i) {
6+
if (memory1 >= memory2) {
7+
memory1 -= i;
8+
} else {
9+
memory2 -= i;
10+
}
11+
++i;
12+
}
13+
return {i, memory1, memory2};
14+
}
15+
};

solution/1800-1899/1860.Incremental Memory Leak/Solution.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
class Solution {
22
public int[] memLeak(int memory1, int memory2) {
33
int i = 1;
4-
while (true) {
4+
while (memory1 >= i || memory2 >= i) {
55
if (memory1 >= memory2) {
6-
if (memory1 < i) {
7-
break;
8-
}
96
memory1 -= i;
107
} else {
11-
if (memory2 < i) {
12-
break;
13-
}
148
memory2 -= i;
159
}
1610
++i;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
class Solution:
22
def memLeak(self, memory1: int, memory2: int) -> List[int]:
33
i = 1
4-
while 1:
4+
while memory1 >= i or memory2 >= i:
55
if memory1 >= memory2:
6-
if memory1 < i:
7-
break
86
memory1 -= i
97
else:
10-
if memory2 < i:
11-
break
128
memory2 -= i
139
i += 1
1410
return [i, memory1, memory2]

0 commit comments

Comments
 (0)