From 8d5e250c0e0c5752204d1c5ca9331b8797664fb4 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 27 Feb 2019 13:47:44 +0800 Subject: [PATCH] Update: description --- .../README.md | 3 +- problems/maximum-average-subarray-i/README.md | 20 +++++---- .../README.md | 22 ++++++---- .../maximum-width-of-binary-tree/README.md | 16 +++---- problems/median-employee-salary/README.md | 3 +- problems/my-calendar-i/README.md | 43 ++++++++++--------- problems/my-calendar-ii/README.md | 43 ++++++++++--------- problems/not-boring-movies/README.md | 18 ++++---- problems/palindromic-substrings/README.md | 36 ++++++++-------- problems/prefix-and-suffix-search/README.md | 40 +++++++++-------- 10 files changed, 129 insertions(+), 115 deletions(-) diff --git a/problems/managers-with-at-least-5-direct-reports/README.md b/problems/managers-with-at-least-5-direct-reports/README.md index 0f273f078..3026ddf5d 100644 --- a/problems/managers-with-at-least-5-direct-reports/README.md +++ b/problems/managers-with-at-least-5-direct-reports/README.md @@ -26,8 +26,7 @@ +------+----------+-----------+----------+ -

Given the Employee table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return: -

+

Given the Employee table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:

 +-------+
diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md
index 7d6fb2398..fa080daf6 100644
--- a/problems/maximum-average-subarray-i/README.md
+++ b/problems/maximum-average-subarray-i/README.md
@@ -11,24 +11,26 @@
 
 ## 643. Maximum Average Subarray I (Easy)
 
-

-Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value. -

+

Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.

+ +

Example 1:

-

Example 1:

 Input: [1,12,-5,-6,50,3], k = 4
 Output: 12.75
 Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75
 
-

-

Note:
+

 

+ +

Note:

+
    -
  1. 1 <= k <= n <= 30,000.
  2. -
  3. Elements of the given array will be in the range [-10,000, 10,000].
  4. +
  5. 1 <= k <= n <= 30,000.
  6. +
  7. Elements of the given array will be in the range [-10,000, 10,000].
-

+ +

 

### Related Topics [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] diff --git a/problems/maximum-product-of-three-numbers/README.md b/problems/maximum-product-of-three-numbers/README.md index 100d7ef21..0c1e1f1bf 100644 --- a/problems/maximum-product-of-three-numbers/README.md +++ b/problems/maximum-product-of-three-numbers/README.md @@ -13,26 +13,32 @@

Given an integer array, find three numbers whose product is maximum and output the maximum product.

-

Example 1:
+

Example 1:

+
 Input: [1,2,3]
 Output: 6
 
-

-

Example 2:
+

 

+ +

Example 2:

+
 Input: [1,2,3,4]
 Output: 24
 
-

-

Note:
+

 

+ +

Note:

+
    -
  1. The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000].
  2. -
  3. Multiplication of any three numbers in the input won't exceed the range of 32-bit signed integer.
  4. +
  5. The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000].
  6. +
  7. Multiplication of any three numbers in the input won't exceed the range of 32-bit signed integer.
-

+ +

 

### Related Topics [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] diff --git a/problems/maximum-width-of-binary-tree/README.md b/problems/maximum-width-of-binary-tree/README.md index 903540ee8..bd59036e5 100644 --- a/problems/maximum-width-of-binary-tree/README.md +++ b/problems/maximum-width-of-binary-tree/README.md @@ -11,11 +11,12 @@ ## 662. Maximum Width of Binary Tree (Medium) -

Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.

+

Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.

The width of one level is defined as the length between the end-nodes (the leftmost and right most non-null nodes in the level, where the null nodes between the end-nodes are also counted into the length calculation.

-

Example 1:
+

Example 1:

+
 Input: 
 
@@ -29,8 +30,8 @@
 Explanation: The maximum width existing in the third level with the length 4 (5,3,null,9).
 
+

Example 2:

-

Example 2:

 Input: 
 
@@ -44,8 +45,8 @@
 Explanation: The maximum width existing in the third level with the length 2 (5,3).
 
+

Example 3:

-

Example 3:

 Input: 
 
@@ -59,7 +60,8 @@
 Explanation: The maximum width existing in the second level with the length 2 (3,2).
 
-

Example 4:
+

Example 4:

+
 Input: 
 
@@ -76,9 +78,7 @@
 
 
-

Note: -Answer will in the range of 32-bit signed integer. -

+

Note: Answer will in the range of 32-bit signed integer.

### Related Topics [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index cbb336399..cf919265f 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -11,8 +11,7 @@ ## 569. Median Employee Salary (Hard) -

-The Employee table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.

+

The Employee table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.

 +-----+------------+--------+
diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md
index b531b3bc4..163949f5d 100644
--- a/problems/my-calendar-i/README.md
+++ b/problems/my-calendar-i/README.md
@@ -11,36 +11,37 @@
 
 ## 729. My Calendar I (Medium)
 
-

-Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking. -

-Your class will have the method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end. -

-A double booking happens when two events have some non-empty intersection (ie., there is some time that is common to both events.) -

-For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a double booking. Otherwise, return false and do not add the event to the calendar. -

- -Your class will be called like this: -MyCalendar cal = new MyCalendar(); -MyCalendar.book(start, end) - -

Example 1:
+

Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.

+ +

Your class will have the method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end.

+ +

A double booking happens when two events have some non-empty intersection (ie., there is some time that is common to both events.)

+ +

For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a double booking. Otherwise, return false and do not add the event to the calendar.

+Your class will be called like this: MyCalendar cal = new MyCalendar(); MyCalendar.book(start, end) + +

Example 1:

+
 MyCalendar();
 MyCalendar.book(10, 20); // returns true
 MyCalendar.book(15, 25); // returns false
 MyCalendar.book(20, 30); // returns true
 Explanation: 
-The first event can be booked.  The second can't because time 15 is already booked by another event.
+The first event can be booked.  The second can't because time 15 is already booked by another event.
 The third event can be booked, as the first event takes every time less than 20, but not including 20.
 
-

-

Note: -

  • The number of calls to MyCalendar.book per test case will be at most 1000.
  • -
  • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
  • -

    +

     

    + +

    Note:

    + +
      +
    • The number of calls to MyCalendar.book per test case will be at most 1000.
    • +
    • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
    • +
    + +

     

    ### Related Topics [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index b7d531bf3..e2b05215e 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -11,21 +11,17 @@ ## 731. My Calendar II (Medium) -

    -Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not cause a triple booking. -

    -Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end. -

    -A triple booking happens when three events have some non-empty intersection (ie., there is some time that is common to all 3 events.) -

    -For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a triple booking. Otherwise, return false and do not add the event to the calendar. -

    - -Your class will be called like this: -MyCalendar cal = new MyCalendar(); -MyCalendar.book(start, end) - -

    Example 1:
    +

    Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not cause a triple booking.

    + +

    Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end.

    + +

    A triple booking happens when three events have some non-empty intersection (ie., there is some time that is common to all 3 events.)

    + +

    For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a triple booking. Otherwise, return false and do not add the event to the calendar.

    +Your class will be called like this: MyCalendar cal = new MyCalendar(); MyCalendar.book(start, end) + +

    Example 1:

    +
     MyCalendar();
     MyCalendar.book(10, 20); // returns true
    @@ -36,17 +32,22 @@ MyCalendar.book(5, 10); // returns true
     MyCalendar.book(25, 55); // returns true
     Explanation: 
     The first two events can be booked.  The third event can be double booked.
    -The fourth event (5, 15) can't be booked, because it would result in a triple booking.
    +The fourth event (5, 15) can't be booked, because it would result in a triple booking.
     The fifth event (5, 10) can be booked, as it does not use time 10 which is already double booked.
     The sixth event (25, 55) can be booked, as the time in [25, 40) will be double booked with the third event;
     the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
     
    -

    -

    Note: -

  • The number of calls to MyCalendar.book per test case will be at most 1000.
  • -
  • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
  • -

    +

     

    + +

    Note:

    + +
      +
    • The number of calls to MyCalendar.book per test case will be at most 1000.
    • +
    • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
    • +
    + +

     

    ### Related Topics [[Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)] diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index d3871624e..10a02fe7e 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -11,13 +11,13 @@ ## 620. Not Boring Movies (Easy) -X city opened a new cinema, many people would like to go to this cinema. -The cinema also gives out a poster indicating the movies’ ratings and descriptions.

    - -Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating. -

    -

    -For example, table cinema: +X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. +

    Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating.

    + +

     

    + +

    For example, table cinema:

    +
     +---------+-----------+--------------+-----------+
     |   id    | movie     |  description |  rating   |
    @@ -30,6 +30,7 @@ For example, table cinema:
     +---------+-----------+--------------+-----------+
     
    For the example above, the output should be: +
     +---------+-----------+--------------+-----------+
     |   id    | movie     |  description |  rating   |
    @@ -38,4 +39,5 @@ For the example above, the output should be:
     |   1     | War       |   great 3D   |   8.9     |
     +---------+-----------+--------------+-----------+
     
    -

    + +

     

    diff --git a/problems/palindromic-substrings/README.md b/problems/palindromic-substrings/README.md index 4e7b7fb68..0f32f6681 100644 --- a/problems/palindromic-substrings/README.md +++ b/problems/palindromic-substrings/README.md @@ -11,35 +11,37 @@ ## 647. Palindromic Substrings (Medium) -

    -Given a string, your task is to count how many palindromic substrings in this string. -

    +

    Given a string, your task is to count how many palindromic substrings in this string.

    -

    -The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. -

    +

    The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.

    + +

    Example 1:

    -

    Example 1:

    -Input: "abc"
    +Input: "abc"
     Output: 3
    -Explanation: Three palindromic strings: "a", "b", "c".
    +Explanation: Three palindromic strings: "a", "b", "c".
     
    -

    -

    Example 2:
    +

     

    + +

    Example 2:

    +
    -Input: "aaa"
    +Input: "aaa"
     Output: 6
    -Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
    +Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
     
    -

    -

    Note:
    +

     

    + +

    Note:

    +
      -
    1. The input string length won't exceed 1000.
    2. +
    3. The input string length won't exceed 1000.
    -

    + +

     

    ### Related Topics [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index 03e939d5f..9a40aa4fa 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -11,30 +11,32 @@ ## 745. Prefix and Suffix Search (Hard) -

    -Given many words, words[i] has weight i. -

    -Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). -It will return the word with given prefix and suffix with maximum weight. If no word exists, return -1. -

    - -

    Examples:
    +

    Given many words, words[i] has weight i.

    + +

    Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will return the word with given prefix and suffix with maximum weight. If no word exists, return -1.

    + +

    Examples:

    +
     Input:
    -WordFilter(["apple"])
    -WordFilter.f("a", "e") // returns 0
    -WordFilter.f("b", "") // returns -1
    -

    +WordFilter(["apple"]) +WordFilter.f("a", "e") // returns 0 +WordFilter.f("b", "") // returns -1 +
    + +

     

    + +

    Note:

    -

    Note:

      -
    1. words has length in range [1, 15000].
    2. -
    3. For each test case, up to words.length queries WordFilter.f may be made.
    4. -
    5. words[i] has length in range [1, 10].
    6. -
    7. prefix, suffix have lengths in range [0, 10].
    8. -
    9. words[i] and prefix, suffix queries consist of lowercase letters only.
    10. +
    11. words has length in range [1, 15000].
    12. +
    13. For each test case, up to words.length queries WordFilter.f may be made.
    14. +
    15. words[i] has length in range [1, 10].
    16. +
    17. prefix, suffix have lengths in range [0, 10].
    18. +
    19. words[i] and prefix, suffix queries consist of lowercase letters only.
    -

    + +

     

    ### Related Topics [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)]