โณ
Promise Race
Promise Race๋ณดํต ๋น๋๊ธฐ +20pts
Problem
Implement a simplified version of Promise.race.
Examples
Input:
promiseRace([delay(100), delay(50)])Output:
๋จผ์ ์๋ฃ๋๋ Promise ๊ฒฐ๊ณผExplanation
์ด ๋ฌธ์ ๋ **Promise.race**์ ๋์ ์๋ฆฌ๋ฅผ ์ดํดํ๊ณ ์ง์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ํ์ตํฉ๋๋ค. ## ํต์ฌ ๊ฐ๋ : Promise.race ๊ฐ์ฅ ๋จผ์ ์๋ฃ๋๋ Promise์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. ### ๋์ ๋ฐฉ์ 1. ๊ฐ์ฅ ๋จผ์ ์ฑ๊ณตํ Promise โ resolve 2. ๊ฐ์ฅ ๋จผ์ ์คํจํ Promise โ reject 3. ์ฒซ ๋ฒ์งธ ๊ฒฐ๊ณผ๋ง ์ฌ์ฉ (๋๋จธ์ง๋ ๋ฌด์) ### ๊ตฌํ ๋ถ์ ```javascript return new Promise((resolve, reject) => { promises.forEach(p => {...
View detailed explanation โKey Concepts
Promise.race ๊ฒฝ์ ์กฐ๊ฑด ์ฒซ ๋ฒ์งธ ์๋ฃ ํ์์์ ํจํด
Time: O(n) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.