전체 글
-
99클럽(3기) - 코테스터디 4일차 TIL # 정렬Algorithm 2024. 8. 3. 10:55
프로그래머스 - H-Index1. 문제 설명어떤 과학자가 발표한 논문 n편이 인용된 횟수를 담은 배열(citations)이 주어진다. 논문 n편 중 h번 이상 인용된 논문이 h편 이상 인용되고, 나머지 논문이 h편 이하 인용되었다면 h의 최댓값을 H-Index라고 하며, H-Index를 구해서 반환해야 한다. 2. 제한 사항1 0 3. 입출력 예 4. 첫 번째 풀이 - Python 'h번 이상 인용된 논문이 h편 이상 인용되었는지 판단하는 기준'을 설정하는 것이 핵심이었다. 이 말 자체를 이해하고 어떻게 문제 풀이에 적용할까 고민하는 시간이 제일 많이 소요된 것 같다. h의 최대값을 구해야하기 때문에 citations를 내림차순으로 정렬해서 가장 많이 인용된 논문부터 몇 편의 논문에 인용되었는지 ..
-
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기) - 코테스터디 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..