본문 바로가기

👨‍💻 DS & Algo/풀이모음17

[leetcode/JS] 40_Combination Sum II 풀이 🎲 문제 40. Combination Sum II Medium 후보 번호(candidates) 모음과 타겟 번호(target)가 주어지면 후보 번호 요소의 합계가 target인 모든 고유한 조합을 찾습니다. 후보자의 각 번호는 조합에서 한 번만 사용할 수 있습니다. 참고: 솔루션 세트는 중복 조합을 포함하지 않아야 합니다. 더보기 Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used .. 2022. 12. 1.
[leetcode/JS] 326_Power of Three 풀이 🎲 문제 326. Power of Three Easy 정수 n이 주어지면 3의 거듭제곱이면 true를 반환한다. 그렇지 않으면 false를 반환한다. n == 3 x제곱인 정수 x가 존재할 경우, 정수 n은 3의 거듭제곱이다. 더보기 Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Input: n = 27 Output: true Explanation: 27 = 33 Example 2: Input: n = 0 Output: false Expl.. 2022. 12. 1.
[leetcode/JS] 290_Word Pattern 풀이 🎲 문제 290. Word Pattern Easy 패턴과 문자열 s가 주어지면 s가 동일한 패턴을 따르는지 확인합니다. 여기서 follow는 패턴의 문자와 s의 비어 있지 않은 단어 사이에 이항이 있는 완전 일치를 의미합니다. ps. 주어진 패턴과 맞는지 확인 하는 문제 더보기 Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Example 1: Input: pattern = "abba", s = "dog cat cat dog.. 2022. 12. 1.
[leetcode/JS] 808_Soup Servings 풀이 🎲 문제 808. Soup Servings Medium 수프에는 유형 A와 유형 B의 두 가지 유형이 있습니다. 처음에는 각 유형의 수프가 n ml입니다. 작업에는 네 가지 종류가 있습니다. 수프 A 100ml와 수프 B 0ml를 제공 수프 A 75ml와 수프 B 25ml 제공 수프 A 50ml와 수프 B 50ml를 제공 수프 A 25ml와 수프 B 75ml를 제공 우리가 수프를 대접할 때, 우리는 그것을 누군가에게 주고, 우리는 더 이상 그것을 가지고 있지 않습니다. 매 턴, 우리는 0.25의 동일한 확률로 네 가지 작업 중에서 선택합니다. 남은 수프의 양이 작업을 완료하기에 충분하지 않은 경우 가능한 한 많이 제공됩니다. 우리는 더 이상 두 가지 유형의 수프가 모두 부족하면 중단합니다. B 수프 10.. 2022. 11. 28.
[leetcode/JS] 387_First Unique Character in a String 풀이 🎲 문제 387. First Unique Character in a String Easy 문자열 s가 주어지면 그 안에 있는 첫 번째 비반복 문자를 찾아 인덱스를 반환합니다. 존재하지 않으면 -1을 반환합니다. 더보기 Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" Output: 0 Example 2: Input: s = "loveleetcode" Output: 2 Example 3: Input: s = "aabb" Output: -1 Constraints: 1 obj[key] === .. 2022. 11. 28.
[leetcode/JS] 292_Nim Game 풀이 🎲 문제 Nim Game - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 292. Nim Game Easy 친구와 함께 다음 Nim 게임을 하고 있습니다. 처음에는 탁자 위에 돌무더기가 놓여 있습니다. 당신과 당신의 친구는 교대로 번갈아가며 당신이 먼저 갑니다. 매 차례마다 차례가 된 사람은 더미에서 1~3개의 돌을 제거합니다. 마지막 돌을 제거하는 사람이 승자입니다. n이 주어졌을 때, 당신과 당신의 친구가 최적으로 플레이한다고 가정하고 게임에서 이길 수 있.. 2022. 11. 28.