[LeetCode] 2300. Successful Pairs of Spells and Potions, Medium
·
CodingTest/LeetCode
1. 문제정수 배열 spells와 potions가 주어질 때, 아래 조건을 만족하는 배열을 반환하라.각 spell * 각 potion이 success를 초과하는 개수를 담는다.spell 별로 시행해서 배열에 담는다.2. 해결function successfulPairs(spells: number[], potions: number[], success: number): number[] { const ans = []; potions.sort((a, b) => a - b); for(let spell of spells) { let left = 0, right = potions.length - 1; let validIndex = potions.length; ..