EasyNo. 2723

Add Two Promises — LeetCode 2723 Python Solution

Topics
JavaScript
Reading time
2 min

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

Related problems
No.ProblemDifficulty
0057Insert IntervalMedium
0192Word FrequencyMedium
0193Valid Phone NumbersEasy
0194Transpose FileMedium
0195Tenth LineEasy
0228Summary RangesEasy

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.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity, invisible to screen sharing.

Free to download. Check it runs on your machine, then pick a plan.