From b86f0561e5649c2b26d73e2ebf3266865d81bcbb Mon Sep 17 00:00:00 2001 From: openset Date: Mon, 27 May 2019 10:19:14 +0800 Subject: [PATCH] Update: description --- problems/detect-capital/README.md | 38 +++++----- problems/falling-squares/README.md | 75 ++++++++----------- problems/lru-cache/README.md | 18 ++--- .../README.md | 10 ++- 4 files changed, 65 insertions(+), 76 deletions(-) diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index 1f6bc2896..8c9f1c328 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -11,38 +11,38 @@ ## 520. Detect Capital (Easy) -

-Given a word, you need to judge whether the usage of capitals in it is right or not. -

+

Given a word, you need to judge whether the usage of capitals in it is right or not.

+ +

We define the usage of capitals in a word to be right when one of the following cases holds:

-

-We define the usage of capitals in a word to be right when one of the following cases holds:

    -
  1. All letters in this word are capitals, like "USA".
  2. -
  3. All letters in this word are not capitals, like "leetcode".
  4. -
  5. Only the first letter in this word is capital if it has more than one letter, like "Google".
  6. +
  7. All letters in this word are capitals, like "USA".
  8. +
  9. All letters in this word are not capitals, like "leetcode".
  10. +
  11. Only the first letter in this word is capital, like "Google".
-Otherwise, we define that this word doesn't use capitals in a right way. -

+Otherwise, we define that this word doesn't use capitals in a right way. + +

 

+

Example 1:

-

Example 1:

-Input: "USA"
+Input: "USA"
 Output: True
 
-

-

Example 2:
+

 

+ +

Example 2:

+
-Input: "FlaG"
+Input: "FlaG"
 Output: False
 
-

-

Note: -The input will be a non-empty word consisting of uppercase and lowercase latin letters. -

+

 

+ +

Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.

### Related Topics [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index b5cb94da3..a5192fcd3 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -12,65 +12,52 @@ ## 699. Falling Squares (Hard)

On an infinite number line (x-axis), we drop given squares in the order they are given.

+

The i-th square dropped (positions[i] = (left, side_length)) is a square with the left-most point being positions[i][0] and sidelength positions[i][1].

-

The square is dropped with the bottom edge parallel to the number line, and from a higher height than all currently landed squares. We wait for each square to stick before dropping the next.

-

The squares are infinitely sticky on their bottom edge, and will remain fixed to any positive length surface they touch (either the number line or another square). Squares dropped adjacent to each other will not stick together prematurely.

-
-

Return a list ans of heights. Each height ans[i] represents the current highest height of any square we have dropped, after dropping squares represented by positions[0], positions[1], ..., positions[i]. -

+

The square is dropped with the bottom edge parallel to the number line, and from a higher height than all currently landed squares. We wait for each square to stick before dropping the next.

+ +

The squares are infinitely sticky on their bottom edge, and will remain fixed to any positive length surface they touch (either the number line or another square). Squares dropped adjacent to each other will not stick together prematurely.

+  + +

Return a list ans of heights. Each height ans[i] represents the current highest height of any square we have dropped, after dropping squares represented by positions[0], positions[1], ..., positions[i].

+ +

Example 1:

-

Example 1:

 Input: [[1, 2], [2, 3], [6, 1]]
 Output: [2, 5, 5]
 Explanation:
-

-After the first drop of positions[0] = [1, 2]: -_aa -_aa -------- -The maximum height of any square is 2. -

-After the second drop of positions[1] = [2, 3]: -__aaa -__aaa -__aaa -_aa__ -_aa__ --------------- -The maximum height of any square is 5. -The larger square stays on top of the smaller square despite where its center -of gravity is, because squares are infinitely sticky on their bottom edge. -

-After the third drop of positions[1] = [6, 1]: -__aaa -__aaa -__aaa -_aa -_aa___a --------------- -The maximum height of any square is still 5. - -Thus, we return an answer of [2, 5, 5].

-

-
+

After the first drop of positions[0] = [1, 2]: _aa _aa ------- The maximum height of any square is 2.

+ +

After the second drop of positions[1] = [2, 3]: __aaa __aaa __aaa _aa__ _aa__ -------------- The maximum height of any square is 5. The larger square stays on top of the smaller square despite where its center of gravity is, because squares are infinitely sticky on their bottom edge.

+ +

After the third drop of positions[1] = [6, 1]: __aaa __aaa __aaa _aa _aa___a -------------- The maximum height of any square is still 5. Thus, we return an answer of [2, 5, 5].

+ +

 

+  + +

Example 2:

-

Example 2:

 Input: [[100, 100], [200, 100]]
 Output: [100, 100]
-Explanation: Adjacent squares don't get stuck prematurely - only their bottom edge can stick to surfaces.
+Explanation: Adjacent squares don't get stuck prematurely - only their bottom edge can stick to surfaces.
 
-

-

Note: -

  • 1 <= positions.length <= 1000.
  • -
  • 1 <= positions[i][0] <= 10^8.
  • -
  • 1 <= positions[i][1] <= 10^6.
  • -

    +

     

    + +

    Note:

    + + + +

     

    ### Related Topics [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index 6f10874bf..1e7046db3 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -11,19 +11,18 @@ ## 146. LRU Cache (Hard) -

    -Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. -

    +

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.

    -

    -get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
    -put(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item. -

    +

    get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
    +put(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.

    + +

    The cache is initialized with a positive capacity.

    Follow up:
    Could you do both operations in O(1) time complexity?

    -

    Example: +

    Example:

    +
     LRUCache cache = new LRUCache( 2 /* capacity */ );
     
    @@ -37,7 +36,8 @@ cache.get(1);       // returns -1 (not found)
     cache.get(3);       // returns 3
     cache.get(4);       // returns 4
     
    -

    + +

     

    ### Related Topics [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index cc41fc75b..bf99c80ff 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -11,11 +11,12 @@ ## 452. Minimum Number of Arrows to Burst Balloons (Medium) -

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of the diameter suffice. Start is always smaller than end. There will be at most 104 balloons.

    +

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of the diameter suffice. Start is always smaller than end. There will be at most 104 balloons.

    -

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps travelling up infinitely. The problem is to find the minimum number of arrows that must be shot to burst all balloons.

    +

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps travelling up infinitely. The problem is to find the minimum number of arrows that must be shot to burst all balloons.

    + +

    Example:

    -

    Example:

     Input:
     [[10,16], [2,8], [1,6], [7,12]]
    @@ -26,7 +27,8 @@
     Explanation:
     One way is to shoot one arrow for example at x = 6 (bursting the balloons [2,8] and [1,6]) and another arrow at x = 11 (bursting the other two balloons).
     
    -

    + +

     

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