Add Two Promises — LeetCode 2723 Python Solution
EasyJavaScript
- Problem
- #2723
- 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
| Measure | Complexity |
|---|---|
| Time | O(n) |
| Space | O(1) to O(n) auxiliary |
Related problems
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.