diff --git a/problems/3sum/README.md b/problems/3sum/README.md
index 3bdb80943..f9061e54a 100644
--- a/problems/3sum/README.md
+++ b/problems/3sum/README.md
@@ -38,3 +38,19 @@ A solution set is:
1. [3Sum Closest](../3sum-closest) (Medium)
1. [4Sum](../4sum) (Medium)
1. [3Sum Smaller](../3sum-smaller) (Medium)
+
+### Hints
+Hint 1
+So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand!
+Hint 2
+For the two-sum problem, if we fix one of the numbers, say x
, we have to scan the entire array to find the next numbery
which is value - x
where value is the input parameter. Can we change our array somehow so that this search becomes faster?
+Hint 3
+The second train of thought for two-sum is, without changing the array, can we use additional space somehow? Like maybe a hash map to speed up the search?
+Hint 1
+The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle.
+
+
+Area = length of shorter vertical line * distance between lines
+
+
+We can definitely get the maximum width container as the outermost lines have the maximum distance between them. However, this container might not be the maximum in size as one of the vertical lines of this container could be really short.
+
+
+
+
+
+
+Hint 2
+Start with the maximum width container and go to a shorter width container if there is a vertical line longer than the current containers shorter line. This way we are compromising on the width but we are looking forward to a longer length container.
+11
is read off as "two 1s"
or 21
.
21
is read off as "one 2
, then one 1"
or 1211
.
Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence.
+Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.
Note: Each term of the sequence of integers will be represented as a string.
@@ -36,13 +36,16 @@Input: 1 Output: "1" +Explanation: This is the base case.
Example 2:
Input: 4 -Output: "1211"+Output: "1211" +Explanation: For n = 3 the term was "21" in which we have two groups "2" and "1", "2" can be read as "12" which means frequency = 1 and value = 2, the same way "1" is read as "11", so the answer is the concatenation of "12" and "11" which is "1211". + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index ceae78a02..a298f932d 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -26,11 +26,11 @@ To the right of 1 there is 0 smaller element. ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 56b92324f..44e118849 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -47,8 +47,8 @@ k =
3
### Related Topics
- [[Greedy](../../tag/greedy/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
+ [[Greedy](../../tag/greedy/README.md)]
### Similar Questions
1. [Remove K Digits](../remove-k-digits) (Medium)
diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md
index 2756ddefe..be8286812 100644
--- a/problems/generalized-abbreviation/README.md
+++ b/problems/generalized-abbreviation/README.md
@@ -26,8 +26,8 @@
### Related Topics
- [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Backtracking](../../tag/backtracking/README.md)]
+ [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
### Similar Questions
1. [Subsets](../subsets) (Medium)
diff --git a/problems/length-of-last-word/README.md b/problems/length-of-last-word/README.md
index 3273ade81..3ac31cbac 100644
--- a/problems/length-of-last-word/README.md
+++ b/problems/length-of-last-word/README.md
@@ -11,11 +11,11 @@
## [58. Length of Last Word (Easy)](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度")
-Given a string s consists of upper/lower-case alphabets and empty space characters ' '
, return the length of last word in the string.
Given a string s consists of upper/lower-case alphabets and empty space characters ' '
, return the length of last word (last word means the last appearing word if we loop from left to right) in the string.
If the last word does not exist, return 0.
-Note: A word is defined as a character sequence consists of non-space characters only.
+Note: A word is defined as a maximal substring consisting of non-space characters only.
Example:
diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 9624f6514..3acd0e9bf 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -42,5 +42,10 @@ nums2 = [2,5,6], n = 3 ### HintsYou are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.
+ +Example 1:
@@ -20,7 +22,7 @@
s = "barfoothefoobarman",
words = ["foo","bar"]
Output: [0,9]
-Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively.
+Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.
The output order does not matter, returning [9,0] is fine too.