diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md index 49da05573..a0e419ed1 100644 --- a/problems/flower-planting-with-no-adjacent/README.md +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -60,3 +60,12 @@ + +### Related Topics + [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + +### Hints +
+Hint 1 +Since each garden is connected to at most 3 gardens, there's always an available color for each garden. For example, if one garden is next to gardens with colors 1, 3, 4, then color #2 is available. +
diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index 2bfb4f352..3aad50c4b 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -39,3 +39,17 @@ Next >
  • 2 <= S.length <= 10^5
  • S consists of lowercase English letters.
  • + +### Related Topics + [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Binary search for the length of the answer. (If there's an answer of length 10, then there are answers of length 9, 8, 7, ...) +
    +
    +Hint 2 +To check whether an answer of length K exists, we can use Rabin-Karp 's algorithm. +
    diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md index aba135cd8..1916aa33e 100644 --- a/problems/partition-array-for-maximum-sum/README.md +++ b/problems/partition-array-for-maximum-sum/README.md @@ -32,3 +32,16 @@
  • 1 <= K <= A.length <= 500
  • 0 <= A[i] <= 10^6
  • + +### Related Topics + [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + +### Hints +
    +Hint 1 +Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1]. +
    +
    +Hint 2 +For j = 1 .. k that keeps everything in bounds, dp[i] is the maximum of dp[i-j] + max(A[i-1], ..., A[i-j]) * j . +
    diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md index ea385a22a..4a68004a9 100644 --- a/problems/robot-bounded-in-circle/README.md +++ b/problems/robot-bounded-in-circle/README.md @@ -28,33 +28,30 @@

    Example 1:

    -Input: "GGLLGG"
    -Output: true
    +Input: "GGLLGG"
    +Output: true
     Explanation: 
     The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
     When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.
     
    -

    Example 2:

    -Input: "GG"
    -Output: false
    +Input: "GG"
    +Output: false
     Explanation: 
    -The robot moves north indefinetely.
    +The robot moves north indefinitely.
     
    -

    Example 3:

    -Input: "GL"
    -Output: true
    +Input: "GL"
    +Output: true
     Explanation: 
     The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...
     
    -

     

    @@ -64,4 +61,16 @@ The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0
  • 1 <= instructions.length <= 100
  • instructions[i] is in {'G', 'L', 'R'}
  • -
    + +### Related Topics + [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + +### Hints +
    +Hint 1 +Calculate the final vector of how the robot travels after executing all instructions once - it consists of a change in position plus a change in direction. +
    +
    +Hint 2 +The robot stays in the circle iff (looking at the final vector) it changes direction (ie. doesn't stay pointing north), or it moves 0. +