Skip to content

Commit 2f43eb8

Browse files
author
Shuo
authored
Merge pull request #761 from openset/develop
Add: new
2 parents 91576fb + 549e008 commit 2f43eb8

File tree

16 files changed

+272
-46
lines changed

16 files changed

+272
-46
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <span id="1321">1321</span> | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth) 🔒 | [MySQL](problems/restaurant-growth) | Medium |
6566
| <span id="1320">1320</span> | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard |
6667
| <span id="1319">1319</span> | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium |
6768
| <span id="1318">1318</span> | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium |
@@ -233,7 +234,7 @@ LeetCode Problems' Solutions
233234
| <span id="1152">1152</span> | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](problems/analyze-user-website-visit-pattern) | Medium |
234235
| <span id="1151">1151</span> | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](problems/minimum-swaps-to-group-all-1s-together) | Medium |
235236
| <span id="1150">1150</span> | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy |
236-
| <span id="1149">1149</span> | [Article Views II](https://leetcode.com/problems/article-views-ii) 🔒 | [MySQL](problems/article-views-ii) | Medium |
237+
| <span id="1149">1149</span> | [Article Views II](https://leetcode.com/problems/article-views-ii "文章浏览 II") 🔒 | [MySQL](problems/article-views-ii) | Medium |
237238
| <span id="1148">1148</span> | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](problems/article-views-i) | Easy |
238239
| <span id="1147">1147</span> | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](problems/longest-chunked-palindrome-decomposition) | Hard |
239240
| <span id="1146">1146</span> | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](problems/snapshot-array) | Medium |
@@ -250,7 +251,7 @@ LeetCode Problems' Solutions
250251
| <span id="1135">1135</span> | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](problems/connecting-cities-with-minimum-cost) | Medium |
251252
| <span id="1134">1134</span> | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](problems/armstrong-number) | Easy |
252253
| <span id="1133">1133</span> | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](problems/largest-unique-number) | Easy |
253-
| <span id="1132">1132</span> | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii) 🔒 | [MySQL](problems/reported-posts-ii) | Medium |
254+
| <span id="1132">1132</span> | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") 🔒 | [MySQL](problems/reported-posts-ii) | Medium |
254255
| <span id="1131">1131</span> | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](problems/maximum-of-absolute-value-expression) | Medium |
255256
| <span id="1130">1130</span> | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](problems/minimum-cost-tree-from-leaf-values) | Medium |
256257
| <span id="1129">1129</span> | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium |

problems/article-views-ii/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array")
1111

12-
## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "")
12+
## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "文章浏览 II")
1313

1414
<p>Table: <code>Views</code></p>
1515

problems/bulb-switcher/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ So you should return 1, because there is only one bulb is on.
2828
</pre>
2929

3030
### Related Topics
31-
[[Math](../../tag/math/README.md)]
3231
[[Brainteaser](../../tag/brainteaser/README.md)]
32+
[[Math](../../tag/math/README.md)]
3333

3434
### Similar Questions
3535
1. [Bulb Switcher II](../bulb-switcher-ii) (Medium)

problems/clone-graph/README.md

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,75 @@
1111

1212
## [133. Clone Graph (Medium)](https://leetcode.com/problems/clone-graph "克隆图")
1313

14-
<p>Given&nbsp;a reference of a node in a&nbsp;<strong><a href="https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph" target="_blank">connected</a></strong>&nbsp;undirected graph, return a <a href="https://en.wikipedia.org/wiki/Object_copying#Deep_copy" target="_blank"><strong>deep copy</strong></a> (clone) of the graph. Each node in the graph contains a val (<code>int</code>) and a list (<code>List[Node]</code>) of its neighbors.</p>
14+
<p>Given a reference of a node in a&nbsp;<strong><a href="https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph" target="_blank">connected</a></strong>&nbsp;undirected graph.</p>
15+
16+
<p>Return a <a href="https://en.wikipedia.org/wiki/Object_copying#Deep_copy" target="_blank"><strong>deep copy</strong></a> (clone) of the graph.</p>
17+
18+
<p>Each node in the graph contains a val (<code>int</code>) and a list (<code>List[Node]</code>) of its neighbors.</p>
19+
20+
<pre>
21+
class Node {
22+
public int val;
23+
public List&lt;Node&gt; neighbors;
24+
}
25+
</pre>
1526

1627
<p>&nbsp;</p>
1728

18-
<p><strong>Example:</strong></p>
29+
<p><strong>Test case format:</strong></p>
1930

20-
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/11/04/133_clone_graph_question.png" style="width: 500px;height:550px" /></p>
31+
<p>For simplicity sake, each&nbsp;node&#39;s value is the same as the node&#39;s index (1-indexed). For example, the first node with&nbsp;<code>val = 1</code>, the second node with <code>val = 2</code>, and so on.&nbsp;The graph is represented in the test case using an adjacency list.</p>
2132

33+
<p><b>Adjacency list</b>&nbsp;is a collection of unordered&nbsp;<b>lists</b>&nbsp;used to represent a finite graph. Each&nbsp;list&nbsp;describes the set of neighbors of a node in the graph.</p>
34+
35+
<p>The given node will&nbsp;always be the first node&nbsp;with&nbsp;<code>val = 1</code>. You must return the <strong>copy of the given node</strong> as a reference to the cloned graph.</p>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Example 1:</strong></p>
39+
<img alt="" src="https://assets.leetcode.com/uploads/2019/11/04/133_clone_graph_question.png" style="width: 500px; height: 550px;" />
2240
<pre>
23-
<strong>Input:
24-
</strong>{&quot;$id&quot;:&quot;1&quot;,&quot;neighbors&quot;:[{&quot;$id&quot;:&quot;2&quot;,&quot;neighbors&quot;:[{&quot;$ref&quot;:&quot;1&quot;},{&quot;$id&quot;:&quot;3&quot;,&quot;neighbors&quot;:[{&quot;$ref&quot;:&quot;2&quot;},{&quot;$id&quot;:&quot;4&quot;,&quot;neighbors&quot;:[{&quot;$ref&quot;:&quot;3&quot;},{&quot;$ref&quot;:&quot;1&quot;}],&quot;val&quot;:4}],&quot;val&quot;:3}],&quot;val&quot;:2},{&quot;$ref&quot;:&quot;4&quot;}],&quot;val&quot;:1}
25-
26-
<strong>Explanation:</strong>
27-
Node 1&#39;s value is 1, and it has two neighbors: Node 2 and 4.
28-
Node 2&#39;s value is 2, and it has two neighbors: Node 1 and 3.
29-
Node 3&#39;s value is 3, and it has two neighbors: Node 2 and 4.
30-
Node 4&#39;s value is 4, and it has two neighbors: Node 1 and 3.
41+
<strong>Input:</strong> adjList = [[2,4],[1,3],[2,4],[1,3]]
42+
<strong>Output:</strong> [[2,4],[1,3],[2,4],[1,3]]
43+
<strong>Explanation:</strong> There are 4 nodes in the graph.
44+
1st node (val = 1)&#39;s neighbors are 2nd node (val = 2) and 4th node (val = 4).
45+
2nd node (val = 2)&#39;s neighbors are 1st node (val = 1) and 3rd node (val = 3).
46+
3rd node (val = 3)&#39;s neighbors are 2nd node (val = 2) and 4th node (val = 4).
47+
4th node (val = 4)&#39;s neighbors are 1st node (val = 1) and 3rd node (val = 3).
3148
</pre>
3249

33-
<p>&nbsp;</p>
50+
<p><strong>Example 2:</strong></p>
51+
<img alt="" src="https://assets.leetcode.com/uploads/2020/01/07/graph.png" style="width: 163px; height: 148px;" />
52+
<pre>
53+
<strong>Input:</strong> adjList = [[]]
54+
<strong>Output:</strong> [[]]
55+
<strong>Explanation:</strong> Note that the input contains one empty list. The graph consists of only one node with val = 1 and it does not have any neighbors.
56+
</pre>
57+
58+
<p><strong>Example 3:</strong></p>
59+
60+
<pre>
61+
<strong>Input:</strong> adjList = []
62+
<strong>Output:</strong> []
63+
<strong>Explanation:</strong> This an empty graph, it does not have any nodes.
64+
</pre>
3465

35-
<p><strong>Note:</strong></p>
66+
<p><strong>Example 4:</strong></p>
67+
<img alt="" src="https://assets.leetcode.com/uploads/2020/01/07/graph-1.png" style="width: 272px; height: 133px;" />
68+
<pre>
69+
<strong>Input:</strong> adjList = [[2],[1]]
70+
<strong>Output:</strong> [[2],[1]]
71+
</pre>
72+
73+
<p>&nbsp;</p>
74+
<p><strong>Constraints:</strong></p>
3675

37-
<ol>
38-
<li>The number of nodes will be between 1 and 100.</li>
39-
<li>The undirected&nbsp;graph is a <a href="https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)#Simple_graph" target="_blank">simple graph</a>,&nbsp;which means no repeated edges and no self-loops in the graph.</li>
40-
<li>Since the graph is undirected, if node <em>p</em>&nbsp;has node <em>q</em>&nbsp;as&nbsp;neighbor, then node <em>q</em>&nbsp;must have node <em>p</em>&nbsp;as neighbor too.</li>
41-
<li>You must return the <strong>copy of the given node</strong> as a reference to the cloned graph.</li>
42-
</ol>
76+
<ul>
77+
<li><code>1 &lt;= Node.val &lt;= 100</code></li>
78+
<li><code>Node.val</code> is unique for each node.</li>
79+
<li>Number of Nodes will not exceed 100.</li>
80+
<li>There is no repeated edges and no self-loops in the graph.</li>
81+
<li>The Graph is connected and all nodes can be visited starting from the given node.</li>
82+
</ul>
4383

4484
### Related Topics
4585
[[Depth-first Search](../../tag/depth-first-search/README.md)]

problems/count-of-smaller-numbers-after-self/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ To the right of 1 there is <b>0</b> smaller element.
2626
</pre>
2727

2828
### Related Topics
29-
[[Binary Search](../../tag/binary-search/README.md)]
30-
[[Divide and Conquer](../../tag/divide-and-conquer/README.md)]
3129
[[Sort](../../tag/sort/README.md)]
3230
[[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)]
3331
[[Segment Tree](../../tag/segment-tree/README.md)]
32+
[[Binary Search](../../tag/binary-search/README.md)]
33+
[[Divide and Conquer](../../tag/divide-and-conquer/README.md)]
3434

3535
### Similar Questions
3636
1. [Count of Range Sum](../count-of-range-sum) (Hard)

problems/create-maximum-number/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ k = <code>3</code>
4747
</pre>
4848

4949
### Related Topics
50-
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
5150
[[Greedy](../../tag/greedy/README.md)]
51+
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
5252

5353
### Similar Questions
5454
1. [Remove K Digits](../remove-k-digits) (Medium)

problems/decompress-run-length-encoded-list/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@
1919

2020
<p>&nbsp;</p>
2121
<p><strong>Example 1:</strong></p>
22-
<pre><strong>Input:</strong> nums = [1,2,3,4]
22+
23+
<pre>
24+
<strong>Input:</strong> nums = [1,2,3,4]
2325
<strong>Output:</strong> [2,4,4,4]
26+
<strong>Explanation:</strong> The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].
27+
The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].
28+
At the end the concatenation [2] + [4,4,4,4] is [2,4,4,4].
2429
</pre>
30+
2531
<p>&nbsp;</p>
2632
<p><strong>Constraints:</strong></p>
2733

problems/distinct-echo-substrings/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## [1316. Distinct Echo Substrings (Hard)](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串")
1313

14-
<p>Return the number of <strong>distinct</strong> non-empty substrings of <code>text</code>&nbsp;that can be written as the concatenation of some string with itself.</p>
14+
<p>Return the number of <strong>distinct</strong> non-empty substrings of <code>text</code>&nbsp;that can be written as the concatenation of some string with itself (i.e. it can be written as <code>a + a</code>&nbsp;where <code>a</code> is some string).</p>
1515

1616
<p>&nbsp;</p>
1717
<p><strong>Example 1:</strong></p>

problems/find-the-team-size/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,47 @@
1111

1212
## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "求团队人数")
1313

14+
<p>Table: <code>Employee</code></p>
15+
<pre>
16+
+---------------+---------+
17+
| Column Name | Type |
18+
+---------------+---------+
19+
| employee_id | int |
20+
| team_id | int |
21+
+---------------+---------+
22+
employee_id is the primary key for this table.
23+
Each row of this table contains the ID of each employee and their respective team.
24+
</pre>
1425

26+
Write an SQL query to find the team size of each of the employees.
27+
28+
Return result table in any order.
29+
30+
The query result format is in the following example:
31+
<pre>
32+
Employee Table:
33+
+-------------+------------+
34+
| employee_id | team_id |
35+
+-------------+------------+
36+
| 1 | 8 |
37+
| 2 | 8 |
38+
| 3 | 8 |
39+
| 4 | 7 |
40+
| 5 | 9 |
41+
| 6 | 9 |
42+
+-------------+------------+
43+
Result table:
44+
+-------------+------------+
45+
| employee_id | team_size |
46+
+-------------+------------+
47+
| 1 | 3 |
48+
| 2 | 3 |
49+
| 3 | 3 |
50+
| 4 | 1 |
51+
| 5 | 2 |
52+
| 6 | 2 |
53+
+-------------+------------+
54+
Employees with Id 1,2,3 are part of a team with team_id = 8.
55+
Employees with Id 4 is part of a team with team_id = 7.
56+
Employees with Id 5,6 are part of a team with team_id = 9.
57+
</pre>

problems/generalized-abbreviation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<p>&nbsp;</p>
2727

2828
### Related Topics
29-
[[Backtracking](../../tag/backtracking/README.md)]
3029
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
30+
[[Backtracking](../../tag/backtracking/README.md)]
3131

3232
### Similar Questions
3333
1. [Subsets](../subsets) (Medium)

problems/height-checker/README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,20 @@
1313

1414
<p>Students are asked to stand in non-decreasing order of heights for an annual photo.</p>
1515

16-
<p>Return the minimum number of students not standing in the right positions.&nbsp; (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.)</p>
16+
<p>Return the minimum number of students that must move in order for all students to be standing in non-decreasing order of height.</p>
1717

1818
<p>&nbsp;</p>
19-
2019
<p><strong>Example 1:</strong></p>
21-
22-
<pre>
23-
<strong>Input: </strong>[1,1,4,2,1,3]
24-
<strong>Output: </strong>3
25-
<strong>Explanation: </strong>
26-
Students with heights 4, 3 and the last 1 are not standing in the right positions.
20+
<pre><strong>Input:</strong> heights = [1,1,4,2,1,3]
21+
<strong>Output:</strong> 3
2722
</pre>
28-
2923
<p>&nbsp;</p>
24+
<p><strong>Constraints:</strong></p>
3025

31-
<p><strong>Note:</strong></p>
32-
33-
<ol>
26+
<ul>
3427
<li><code>1 &lt;= heights.length &lt;= 100</code></li>
3528
<li><code>1 &lt;= heights[i] &lt;= 100</code></li>
36-
</ol>
29+
</ul>
3730

3831
### Related Topics
3932
[[Array](../../tag/array/README.md)]

problems/minimum-distance-to-type-a-word-using-two-fingers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected")
99

10-
Next >
10+
[Next >](../restaurant-growth "Restaurant Growth")
1111

1212
## [1320. Minimum Distance to Type a Word Using Two Fingers (Hard)](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离")
1313

problems/reported-posts-ii/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](../largest-unique-number "Largest Unique Number")
1111

12-
## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "")
12+
## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "报告的记录 II")
1313

1414
<p>Table: <code>Actions</code></p>
1515

problems/restaurant-growth/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers")
9+
                
10+
Next >
11+
12+
## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "")
13+
14+
<p>Table: <code>Customer</code></p>
15+
<pre>
16+
+---------------+---------+
17+
| Column Name | Type |
18+
+---------------+---------+
19+
| customer_id | int |
20+
| name | varchar |
21+
| visited_on | date |
22+
| amount | int |
23+
+---------------+---------+
24+
(customer_id, visited_on) is the primary key for this table.
25+
This table contains data about customer transactions in a restaurant.
26+
visited_on is the date on which the customer with ID (customer_id) have visited the restaurant.
27+
amount is the total paid by a customer.
28+
</pre>
29+
30+
You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day).
31+
32+
Write an SQL query to compute moving average of how much customer paid in a 7 days window (current day + 6 days before) .
33+
34+
The query result format is in the following example:
35+
36+
Return result table ordered by visited_on.
37+
38+
average_amount should be rounded to 2 decimal places, all dates are in the format ('YYYY-MM-DD').
39+
40+
<pre>
41+
Customer table:
42+
+-------------+--------------+--------------+-------------+
43+
| customer_id | name | visited_on | amount |
44+
+-------------+--------------+--------------+-------------+
45+
| 1 | Jhon | 2019-01-01 | 100 |
46+
| 2 | Daniel | 2019-01-02 | 110 |
47+
| 3 | Jade | 2019-01-03 | 120 |
48+
| 4 | Khaled | 2019-01-04 | 130 |
49+
| 5 | Winston | 2019-01-05 | 110 |
50+
| 6 | Elvis | 2019-01-06 | 140 |
51+
| 7 | Anna | 2019-01-07 | 150 |
52+
| 8 | Maria | 2019-01-08 | 80 |
53+
| 9 | Jaze | 2019-01-09 | 110 |
54+
| 1 | Jhon | 2019-01-10 | 130 |
55+
| 3 | Jade | 2019-01-10 | 150 |
56+
+-------------+--------------+--------------+-------------+
57+
58+
Result table:
59+
+--------------+--------------+----------------+
60+
| visited_on | amount | average_amount |
61+
+--------------+--------------+----------------+
62+
| 2019-01-07 | 860 | 122.86 |
63+
| 2019-01-08 | 840 | 120 |
64+
| 2019-01-09 | 840 | 120 |
65+
| 2019-01-10 | 1000 | 142.86 |
66+
+--------------+--------------+----------------+
67+
68+
1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86
69+
2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120
70+
3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120
71+
4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86
72+
</pre>

0 commit comments

Comments
 (0)