본문 바로가기

Data Structure & Algorithms/Hasing6

[Hashing] 2260. Minimum Consecutive Cards to Pick Up https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up/ Minimum Consecutive Cards to Pick Up - LeetCode Can you solve this real interview question? Minimum Consecutive Cards to Pick Up - You are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same value. Return the minimum n leetcode.com 난이도: medium .. 2023. 3. 17.
[Hashing] 해쉬를 핵심만 정리해보자 해쉬 테이블 (hash table) key,value 로 데이터를 저장하는 자료구조 , 정말빠르게 O(1)으로 자료를 검색할 수 있는 기적의 구조 (어떻게 검색을하길래?) 내부적으로 배열(버킷) 을 사용하여 데이터를 저장해서. 해쉬 함수는 고유의 KEY값에 따라 Value(bucket)에 전달해주는데 이를 이용해 암호학(내부 해쉬 함수가 어떻게 생긴지 모르니 밖에서는 고유 key값으로만 내부에 접근할수있는 원리) 에도 사용!! 근데 만약 두개 다른 key가 같은 value를 지칭하게 된다면? -> 충돌. 이를 해결하기위해 체이닝(chaining기법을 사용) 체이닝의 장점: 1. 탐색 저장 삭제시 연결리스트(linked list)에서 독립적으로 수행 -> 오버플로우가 발생해도 시간이 효율적 2. 연결 리스.. 2023. 3. 12.
[Hashing] 383. Ransom Note 출처: leetcode Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example 1: Input: ransomNote = "a", magazine = "b" Output: false Example 2: Input: ransomNote = "aa", magazine = "ab" Output: false Example 3: Input: ransomNote = "aa", magazine = .. 2023. 1. 6.
[Hashing] Find Players With Zero or One Losses 해쉬에 대해 조금 더 이해도가 생긴듯. 혼자 풀기성공 You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where: answer[0] is a list of all players that have not lost any matches. answer[1] is a list of all players that have lost exactly one match. The values in the two lists should be returned in.. 2023. 1. 6.
[Hashing] Largest Unique Number Given an integer array nums, return the largest integer that only occurs once. If no integer occurs once, return -1. Example 1: Input: nums = [5,7,3,9,4,9,8,3,1] Output: 8 Explanation: The maximum integer in the array is 9 but it is repeated. The number 8 occurs only once, so it is the answer. Example 2: Input: nums = [9,9,8,8] Output: -1 Explanation: There is no number that occurs only once. Co.. 2023. 1. 4.
[Hashing] Maximum Number of Balloons 출처 : leetcode - DS course 문제: Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in text at most once. Return the maximum number of instances that can be formed. Input: text = "nlaebolko" Output: 1 Input: text = "loonbalxballpoon" Output: 2 Input: text = "leetcode" Output: 0 Constraints: 1 2023. 1. 3.