전체 글39 [DSA][Array & Hashing] 06. Product of Array Except Self LeetCode 238 06. Product of Array Except SelfGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.You must write an algorithm that runs in O(n) time and without using the division operation. [질문하기]- 배열에 0이 하나 이상 포함될 수 있나요? [아.. 2025. 5. 20. [DSA][Array & Hashing] 05. Top K Frequent Elements LeetCode 347 05. Top K Frequent ElementsGiven an integer array nums and an integer k, return the k most frequent elements.You may return the answer in any order. [질문하기]- 빈도가 같은 요소가 여러 개 있는 경우 모두 반환해야 하나요?- 배열에 음수도 포함될 수 있나요? YES [아이디어]- 정렬- Heap- Bucket Sort [풀이 1] Hash with Sortingclass Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: # 1. 빈도 hash 생성 c.. 2025. 5. 19. [DSA][Array & Hashing] 04. Group Anagrams LeetCode 49 04. Group AnagramsGiven an array of strings strs, group the anagrams together. You can return the answer in any order. [질문하기]- 배열의 길이와 문자열의 길이는 최대 몇인가요?- 그룹 간의 출력 순서도 고려해야 하나요?- 배열의 문자열에 소문자/대문자가 혼합될 수 있나요? 알파벳이 아닌 문자가 포함될 수 있나요? [아이디어]Counter를 hashMap의 key로 사용해 버리자 [풀이 1] Hash with Sortingclass Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: hashM.. 2025. 5. 18. [DSA][Array & Hashing] 03. Two Sum LeetCode 1 03. Two SumGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order. [질문하기]- 정수 배열에 중복된 숫자가 있을 수 있나요?- 배열이 정렬되어 있나요?- 정답은 단 하나라고 가정해도 될까요? or 항상 valid 한 정답이 있나요? (YES)- 정답으로 반환.. 2025. 5. 17. 이전 1 2 3 4 ··· 10 다음