자료구조와 알고리즘12 [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] 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. [DSA][Array & Hashing] 02. Valid Anagram LeetCode 241 02. Valid AnagramGiven two strings s and t, return true if t is an anagram of s, and false otherwise. [질문하기]- 문자열이 대소문자를 구분해야 하나요?- 문자열에 알파벳 외에 공백이나 특수문자가 포함될 수 있나요? ex) a b c = abc?- 빈 문자열이 입력으로 올 수 있나요? 만약 그렇다면, true를 return 해야 하나요? [아이디어]아나그램은 글자의 순서만을 바꿔서 다른 단어를 만드는 것이다. 원래 단어에 포함된 글자를 모두, 한 번씩만 사용해서 만들 수 있는지를 확인해야 한다. [풀이 1] Hash using arrayclass Solution: def isAnagram(s.. 2025. 5. 16. 이전 1 2 3 다음