EasyNo. 2723
Add Two Promises — LeetCode 2723 Python Solution
- Topics
- JavaScript
- Reading time
- 2 min
- Source
- leetcode.com
The problem
Given two promises promise1 and promise2, return a new promise. promise1 and promise2 will both resolve with a number.
Example
- Input
- promise1 = new Promise(resolve => setTimeout(() => resolve(2), 20)),
- Output
- 7
- Explanation
- The two input promises resolve with the values of 2 and 5 respectively. The returned promise should resolve with a value of 2 + 5 = 7. The time the returned promise resolves is not judged for this problem.
Complexity
- Time
- O(n)
- Space · auxiliary
- O(1) to O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0057 | Insert Interval | Medium |
| 0192 | Word Frequency | Medium |
| 0193 | Valid Phone Numbers | Easy |
| 0194 | Transpose File | Medium |
| 0195 | Tenth Line | Easy |
| 0228 | Summary Ranges | Easy |
Frequently asked questions
- How hard is LeetCode 2723. Add Two Promises?
LeetCode 2723. Add Two Promises is rated Easy on LeetCode.
- What topics does LeetCode 2723. Add Two Promises cover?
LeetCode 2723. Add Two Promises is tagged JavaScript on LeetCode.