From 73f7be30e6db155f8fa0fd897e8713fd04e3b285 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 19 Jun 2019 20:48:28 +0800 Subject: [PATCH] Add: v1.3.2 --- internal/version/version.go | 2 +- problems/game-play-analysis-i/README.md | 14 ++++++++++ .../game-play-analysis-i/mysql_schemas.sql | 7 +++++ problems/game-play-analysis-ii/README.md | 14 ++++++++++ .../game-play-analysis-ii/mysql_schemas.sql | 7 +++++ problems/game-play-analysis-iii/README.md | 14 ++++++++++ .../game-play-analysis-iii/mysql_schemas.sql | 7 +++++ problems/game-play-analysis-iv/README.md | 14 ++++++++++ .../game-play-analysis-iv/mysql_schemas.sql | 7 +++++ problems/high-five/README.md | 28 ++++++++++++++++++- .../README.md | 19 +++++++++++++ 11 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 problems/game-play-analysis-i/README.md create mode 100644 problems/game-play-analysis-i/mysql_schemas.sql create mode 100644 problems/game-play-analysis-ii/README.md create mode 100644 problems/game-play-analysis-ii/mysql_schemas.sql create mode 100644 problems/game-play-analysis-iii/README.md create mode 100644 problems/game-play-analysis-iii/mysql_schemas.sql create mode 100644 problems/game-play-analysis-iv/README.md create mode 100644 problems/game-play-analysis-iv/mysql_schemas.sql diff --git a/internal/version/version.go b/internal/version/version.go index 81a77db46..ddba303bf 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -7,7 +7,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.3.1" +const version = "1.3.2" var CmdVersion = &base.Command{ Run: runVersion, diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md new file mode 100644 index 000000000..fdf78733e --- /dev/null +++ b/problems/game-play-analysis-i/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii "Inorder Successor in BST II") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii "Game Play Analysis II") + +## 511. Game Play Analysis I (Easy) + + diff --git a/problems/game-play-analysis-i/mysql_schemas.sql b/problems/game-play-analysis-i/mysql_schemas.sql new file mode 100644 index 000000000..519a7e42c --- /dev/null +++ b/problems/game-play-analysis-i/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int); +Truncate table Activity; +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5'); +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-05-02', '6'); +insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5'); diff --git a/problems/game-play-analysis-ii/README.md b/problems/game-play-analysis-ii/README.md new file mode 100644 index 000000000..fb0791978 --- /dev/null +++ b/problems/game-play-analysis-ii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i "Game Play Analysis I") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value "Find Bottom Left Tree Value") + +## 512. Game Play Analysis II (Easy) + + diff --git a/problems/game-play-analysis-ii/mysql_schemas.sql b/problems/game-play-analysis-ii/mysql_schemas.sql new file mode 100644 index 000000000..519a7e42c --- /dev/null +++ b/problems/game-play-analysis-ii/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int); +Truncate table Activity; +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5'); +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-05-02', '6'); +insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5'); diff --git a/problems/game-play-analysis-iii/README.md b/problems/game-play-analysis-iii/README.md new file mode 100644 index 000000000..dc8bb17e1 --- /dev/null +++ b/problems/game-play-analysis-iii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii "Lonely Pixel II") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl "Encode and Decode TinyURL") + +## 534. Game Play Analysis III (Medium) + + diff --git a/problems/game-play-analysis-iii/mysql_schemas.sql b/problems/game-play-analysis-iii/mysql_schemas.sql new file mode 100644 index 000000000..cb1a27f6d --- /dev/null +++ b/problems/game-play-analysis-iii/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int); +Truncate table Activity; +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5'); +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-05-02', '6'); +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '3', '2017-06-25', '1'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5'); diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md new file mode 100644 index 000000000..0f93f406b --- /dev/null +++ b/problems/game-play-analysis-iv/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i "Student Attendance Record I") + +## 550. Game Play Analysis IV (Medium) + + diff --git a/problems/game-play-analysis-iv/mysql_schemas.sql b/problems/game-play-analysis-iv/mysql_schemas.sql new file mode 100644 index 000000000..19191e384 --- /dev/null +++ b/problems/game-play-analysis-iv/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int); +Truncate table Activity; +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5'); +insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-02', '6'); +insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0'); +insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5'); diff --git a/problems/high-five/README.md b/problems/high-five/README.md index b2beae86d..51acaa3f2 100644 --- a/problems/high-five/README.md +++ b/problems/high-five/README.md @@ -11,12 +11,38 @@ ## 1086. High Five (Easy) +

Given a list of scores of different students, return the average score of each student's top five scores in the order of each student's id.

+

Each entry items[i] has items[i][0] the student's id, and items[i][1] the student's score.  The average score is calculated using integer division.

+ +

 

+ +

Example 1:

+ +
+Input: [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]
+Output: [[1,87],[2,88]]
+Explanation: 
+The average of the student with id = 1 is 87.
+The average of the student with id = 2 is 88.6. But with integer division their average converts to 88.
+
+ +

 

+ +

Note:

+ +
    +
  1. 1 <= items.length <= 1000
  2. +
  3. items[i].length == 2
  4. +
  5. The IDs of the students is between 1 to 1000
  6. +
  7. The score of the students is between 1 to 100
  8. +
  9. For each student, there are at least 5 scores
  10. +
### Related Topics + [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] ### Hints
diff --git a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md index 89aff8e84..a55b68d9c 100644 --- a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md +++ b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md @@ -36,6 +36,16 @@ Output: [1,2,3,4,null,null,7,8,9,null,14]root = [5,4,8,11,null,17,4,7,1,null,null,5,3], limit = 22 Output: [5,4,8,11,null,17,4,7,null,null,null,5] + +

 

+ +

Example 3:

+ +
+
+Input: root = [1,2,-3,-5,null,4,null], limit = -1
+
+Output: [1,null,-3,4]

 

@@ -51,3 +61,12 @@ Output: [5,4,8,11,null,17,4,7,null,null,nul
 
+ +### Related Topics + [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + +### Hints +
+Hint 1 +Consider a DFS traversal of the tree. You can keep track of the current path sum from root to this node, and you can also use DFS to return the minimum value of any path from this node to the leaf. This will tell you if this node is insufficient. +