Skip to content

Commit bb28371

Browse files
author
Shuo
authored
Merge pull request #573 from openset/develop
Update: Hints
2 parents a345b96 + 2f93e48 commit bb28371

File tree

81 files changed

+181
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+181
-2
lines changed

internal/leetcode/question_data.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ func (question questionType) getHints() []byte {
172172
hints := question.Hints
173173
var buf bytes.Buffer
174174
if len(hints) > 0 {
175-
buf.WriteString("\n### Hints\n")
175+
buf.WriteString("\n### Hints")
176176
}
177177
for i, hint := range hints {
178-
buf.WriteString(fmt.Sprintf("<details>\n<summary>Hint %d</summary>\n%s\n</details>\n", i+1, filterContents(hint)))
178+
buf.WriteString(fmt.Sprintf("\n<details>\n<summary>Hint %d</summary>\n%s\n</details>\n", i+1, filterContents(hint)))
179179
}
180180
return buf.Bytes()
181181
}

problems/add-digits/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ Could you do it without any loop/recursion in O(1) runtime?</p>
3636
<summary>Hint 1</summary>
3737
A naive implementation of the above process is trivial. Could you come up with other methods?
3838
</details>
39+
3940
<details>
4041
<summary>Hint 2</summary>
4142
What are all the possible results?
4243
</details>
44+
4345
<details>
4446
<summary>Hint 3</summary>
4547
How do they occur, periodically or randomly?
4648
</details>
49+
4750
<details>
4851
<summary>Hint 4</summary>
4952
You may find this <a href="https://en.wikipedia.org/wiki/Digital_root" target="_blank">Wikipedia article</a> useful.

problems/array-partition-i/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ Given an array of <b>2n</b> integers, your task is to group these integers into
3939
<summary>Hint 1</summary>
4040
Obviously, brute force won't help here. Think of something else, take some example like 1,2,3,4.
4141
</details>
42+
4243
<details>
4344
<summary>Hint 2</summary>
4445
How will you make pairs to get the result? There must be some pattern.
4546
</details>
47+
4648
<details>
4749
<summary>Hint 3</summary>
4850
Did you observe that- Minimum element gets add into the result in sacrifice of maximum element.
4951
</details>
52+
5053
<details>
5154
<summary>Hint 4</summary>
5255
Still won't able to find pairs? Sort the array and try to find the pattern.

problems/binary-tree-tilt/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ Tilt of binary tree : 0 + 0 + 1 = 1
4747
<summary>Hint 1</summary>
4848
Don't think too much, this is an easy problem. Take some small tree as an example.
4949
</details>
50+
5051
<details>
5152
<summary>Hint 2</summary>
5253
Can a parent node use the values of its child nodes? How will you implement it?
5354
</details>
55+
5456
<details>
5557
<summary>Hint 3</summary>
5658
May be recursion and tree traversal can help you in implementing.
5759
</details>
60+
5861
<details>
5962
<summary>Hint 4</summary>
6063
What about postorder traversal, using values of left and right childs?

problems/binary-watch/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<summary>Hint 1</summary>
4444
Simplify by seeking for solutions that involve comparing bit counts.
4545
</details>
46+
4647
<details>
4748
<summary>Hint 2</summary>
4849
Consider calculating all possible times for comparison purposes.

problems/camelcase-matching/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@
6666
<summary>Hint 1</summary>
6767
Given a single pattern and word, how can we solve it?
6868
</details>
69+
6970
<details>
7071
<summary>Hint 2</summary>
7172
One way to do it is using a DP (pos1, pos2) where pos1 is a pointer to the word and pos2 to the pattern and returns true if we can match the pattern with the given word.
7273
</details>
74+
7375
<details>
7476
<summary>Hint 3</summary>
7577
We have two scenarios: The first one is when `word[pos1] == pattern[pos2]`, then the transition will be just DP(pos1 + 1, pos2 + 1). The second scenario is when `word[pos1]` is lowercase then we can add this character to the pattern so that the transition is just DP(pos1 + 1, pos2)

problems/closest-binary-search-tree-value-ii/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ Consider implement these two helper functions:
2929
<li><code>getSuccessor(N)</code>, which returns the next larger node to N.</li>
3030
</ol>
3131
</details>
32+
3233
<details>
3334
<summary>Hint 2</summary>
3435
Try to assume that each node has a parent pointer, it makes the problem much easier.
3536
</details>
37+
3638
<details>
3739
<summary>Hint 3</summary>
3840
Without parent pointer we just need to keep track of the path from the root to the current node using a stack.
3941
</details>
42+
4043
<details>
4144
<summary>Hint 4</summary>
4245
You would need two stacks to track the path in finding predecessor and successor node separately.

problems/contains-duplicate-iii/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<summary>Hint 1</summary>
5454
Time complexity O(n logk) - This will give an indication that sorting is involved for k elements.
5555
</details>
56+
5657
<details>
5758
<summary>Hint 2</summary>
5859
Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state and it is not necessary to sort next overlapping set of k numbers again.

problems/copy-list-with-random-pointer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ Node 2&#39;s value is 2, its next pointer points to null and its random pointer
5050
<summary>Hint 1</summary>
5151
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node.
5252
</details>
53+
5354
<details>
5455
<summary>Hint 2</summary>
5556
You may want to use extra space to keep <b>old node ---> new node</b> mapping to prevent creating multiples copies of same node.
5657
</details>
58+
5759
<details>
5860
<summary>Hint 3</summary>
5961
We can avoid using extra space for old node ---> new node mapping, by tweaking the original linked list. Simply interweave the nodes of the old and copied list.
@@ -63,6 +65,7 @@ Old List: A --> B --> C --> D
6365
InterWeaved List: A --> A' --> B --> B' --> C --> C' --> D --> D'
6466
</pre>
6567
</details>
68+
6669
<details>
6770
<summary>Hint 4</summary>
6871
The interweaving is done using <b>next</b> pointers and we can make use of interweaved structure to get the correct reference nodes for <b>random</b> pointers.

problems/count-and-say/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The following are the terms from n=1 to n=10 of the count-and-say sequence:
6868
10. 13211311123113112211
6969
</pre>
7070
</details>
71+
7172
<details>
7273
<summary>Hint 2</summary>
7374
To generate the <i>n</i><sup>th</sup> term, just <i>count and say</i> the <i>n</i>-1<sup>th</sup> term.

0 commit comments

Comments
 (0)