전체 글
-
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기) - 코테스터디 24일차 TIL # Stack # Queue카테고리 없음 2024. 6. 22. 11:52
LeetCode - 1700. Number of Students Unable to Eat LunchThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:If th..
-
99클럽(2기) - 코테스터디 23일차 TIL # Array카테고리 없음 2024. 6. 22. 10:48
LeetCode - 2089. Find Target Indices After Sorting ArrayYou are given a 0-indexed integer array nums and a target element target.A target index is an index i such that nums[i] == target.Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order. 1. 첫 번째 풀이 답을 반환..
-
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..
-
99클럽(2기) - 코테스터디 20일차 TIL # ArrayAlgorithm 2024. 6. 18. 09:24
LeetCode - 1773. Count Items Matching a RuleYou are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue. Example 1:Input: items = [["phone","blue","pixel"],["computer","silver","lenovo"],["phone","gold","iphone"]], ruleKey = "color", ruleValue = "silver"..
-
99클럽(2기) - 코테스터디 19일차 TIL # 완전 탐색Algorithm 2024. 6. 17. 05:54
LeetCode - 2942. Find Words Containing CharacterYou are given a 0-indexed array of strings words and a character x.Return an array of indices representing the words that contain the character x.Note that the returned array may be in any order. 1. 첫 번째 풀이 리스트 컴프리핸션을 이용해 한 줄로 풀었다. enumerate 함수를 사용해서 words의 인덱스 idx와 요소 word를 반복문으로 순회하며 x가 word 안에 포함되어 있으면 해당 인덱스를 추가한 리스트를 반환한다. from typing import L..