Algorithm
-
99클럽(3기) - 코테스터디 3일차 TIL # 정렬Algorithm 2024. 8. 1. 22:56
프로그래머스 - 카드 뭉치1. 문제 설명문자열로 이루어진 배열 cards1, cards2와 원하는 단어 배열 goal이 파라미터로 주어질 때, cards1과 cards2에 적힌 단어들로 goal을 만들 수 있다면 "Yes", 만들 수 없다면 "No"를 반환해야 한다. 2. 제한 사항1 1 cards1과 cards2에는 서로 다른 단어만 존재함 2 1 goal의 원소는 cards1과 cards2의원소들로만 구성됨 cards1, cards2, goal의 문자열들은 모두 알파벳 소문자로만 구성됨 3. 입출력 예 4. 나의 풀이1) cards1과 cards2의 인덱스를 추적하기 위한 변수 할당cards1의 인덱스를 추적할 idx1, cards2의 인덱스를 추적할 idx2를 각각 0으로 초기화한다. 2) g..
-
99클럽(2기) - 코테스터디 29일차 TIL # Greedy # StringAlgorithm 2024. 6. 28. 20:44
LeetCode - 2864. Maximum Odd Binary NumberYou are given a binary string s that contains at least one '1'.You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination.Return a string representing the maximum odd binary number that can be created from the given combination.Note that the resulting string can..
-
99클럽(2기) - 코테스터디 28일차 TIL # Priority Queue # Max HeapAlgorithm 2024. 6. 27. 22:48
LeetCode - 1337. The K Weakest Rows in a MatrixYou are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.A row i is weaker than a row j if one of the following is true:The number of soldiers in row i is less than the number..
-
99클럽(2기) - 코테스터디 27일차 TIL # Max Heap # Priority QueueAlgorithm 2024. 6. 26. 21:54
LeetCode - 2500. Delete Greatest Value in Each Row You are given an m x n matrix grid consisting of positive integers.Perform the following operation until grid becomes empty:Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them.Add the maximum of deleted elements to the answer. Note that the number of columns decreases by one after each op..
-
99클럽(2기) - 코테스터디 26일차 TIL # StackAlgorithm 2024. 6. 26. 01:25
LeetCode - 682. Baseball GameYou are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record.You are given a list of strings operations, where operations[i] is the ith operation you must apply to the record and is one of the following:An integer x.Record a new score of x.'+'.Record a new score that is the sum of the previous two sco..
-
99클럽(2기) - 코테스터디 25일차 TIL # StackAlgorithm 2024. 6. 25. 10:32
LeetCode - 1475. Final Prices With a Special Discount in a Shop You are given an integer array prices where prices[i] is the price of the ith item in a shop.There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] Return an integer array answer where answer[i] is..
-
99클럽(2기) - 코테스터디 22일차 TIL # StringAlgorithm 2024. 6. 20. 10:50
LeetCode - Decode the MessageYou are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table.Align the substitution table with the regular English alphabet.Each letter in message is then substituted using..
-
99클럽(2기) - 코테스터디 21일차 TIL # Array # StringAlgorithm 2024. 6. 18. 23:21
LeetCode - 1528. Shuffle StringYou are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.Return the shuffled string. 1. 첫 번째 풀이1) s를 구성하는 글자의 인덱스와 해당 글자를 담을 딕셔너리 strings 생성 defaultdict를 이용해 s를 구성하는 글자의 인덱스를 키로, 해당 글자를 값으로 갖는 딕셔너리 strings를 생성한다. 2) s를 순회하며 indices[i..