feat(seed): add videos, images, and accordion hints for test data

This commit is contained in:
cfngc4594 2025-03-27 14:10:03 +08:00
parent 869957de19
commit e1ce93346a

View File

@ -71,6 +71,8 @@ You may assume that each input would have **exactly one solution**, and you may
You can return the answer in any order. You can return the answer in any order.
<VideoEmbed platform="bilibili" id="BV1TC411b7H8" />
## Examples ## Examples
### Example 1 ### Example 1
@ -113,10 +115,24 @@ Output: [0,1]
Only one valid answer exists. Only one valid answer exists.
</div> </div>
**Follow-up:** Can you come up with an algorithm that is less than $O(n^2)$ time complexity?
--- ---
**Follow-up:** Can you come up with an algorithm that is less than $O(n^2)$ time complexity?`, <Accordion title="Hint 1">
solution: `## Approach 1: Brute Force A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations.
</Accordion>
<Accordion title="Hint 2">
So, if we fix one of the numbers, say \`x\`, we have to scan the entire array to find the next number \`y\` which is \`value - x\` where value is the input parameter. Can we change our array somehow so that this search becomes faster?
</Accordion>
<Accordion title="Hint 3">
The second train of thought is, without changing the array, can we use additional space somehow? Like maybe a hash map to speed up the search?
</Accordion>`,
solution: `<VideoEmbed platform="youtube" id="tSI98g3PDyE" />
## Approach 1: Brute Force
### Algorithm ### Algorithm
@ -313,6 +329,8 @@ You may assume the two numbers do not contain any leading zero, except the numbe
### Example 1 ### Example 1
![Example 1](https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg)
\`\`\`shell \`\`\`shell
Input: l1 = [2,4,3], l2 = [5,6,4] Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8] Output: [7,0,8]
@ -352,6 +370,8 @@ It is guaranteed that the list represents a number that does not have leading ze
Keep track of the carry using a variable and simulate digits-by-digits sum starting from the head of list, which contains the least-significant digit. Keep track of the carry using a variable and simulate digits-by-digits sum starting from the head of list, which contains the least-significant digit.
![Figure 1](https://leetcode.com/problems/add-two-numbers/Figures/2_add_two_numbers.svg)
*Figure 1. Visualization of the addition of two numbers: $342 + 465 = 807$.* *Figure 1. Visualization of the addition of two numbers: $342 + 465 = 807$.*
*Each node contains a single digit and the digits are stored in reverse order.* *Each node contains a single digit and the digits are stored in reverse order.*