전체 글 154

LeetCode1717. Maximum Score From Removing Substrings

https://leetcode.com/problems/maximum-score-from-removing-substrings/submissions/1321816444/?envType=daily-question&envId=2024-07-12       1. 문제 및 접근   1717. Maximum Score From Removing Substrings String 값을 주고, ab를 지우면 x점수, ba를 지우면 y점수를 얻을 수 있다최대 얻을 수 있는 점수를 반환 높은 점수대로 그리디를 쓰면 될 것 같은데 전체 탐색하니 시간초과StringBulider에 담아서 담을 때 마다 판별 후 삭제하자   Constraints:1 1 s consists of lowercase English letters.     ..

알고리즘 2024.07.16

99클럽 코테 스터디 40일차 TIL Optimal Partition of String

https://leetcode.com/problems/optimal-partition-of-string/description/ 비트연산자map     1. 문제 및 접근   2405. Optimal Partition of String 주어진 s의 서브 스트링을 구성하는데, 중복된 char가 없게 만들어야 한다최소의 subString 갯수를 반환"abacaba" 라면 "ab" "ac" ,"aba"로 나눴다면  aba에서 a가 2개라 안됨s = abacaba 라면 앞에서부터 시작해서 있는 수 중 같은 수가 들어오면 그전까지 담기 ?각 substring은 중복되도 되는 듯 하다   Constraints:1 s consists of only English lowercase letters.       2. 풀이 ..

알고리즘 2024.06.28

99클럽 코테 스터디 39일차 TIL Reduce Array Size to The Half

https://leetcode.com/problems/reduce-array-size-to-the-half/    그리디map.merge      1. 문제 및 접근  1338. Reduce Array Size to The Half 배열이 주어지면 배열 안에 있는 수 중 하나를 골라 그 수를 다 없앨 수 있다.그럴 때 반 이상 줄일 수 있는 최소의 수의 최소 갯수 반환 arr = [3,3,3,3,5,5,5,2,2,7]map으로 찾고, 그 수를 돌면서 반 이상되면 바로 리턴 ? 3 =4 5=3 2=2 7=1키 값은 상관 없음 번호로 부여하고, 몇개인지가 중요   Constraints:2 arr.length is even.1      2.  풀이 public int minSetSize(int[] arr) {..

알고리즘 2024.06.27

99클럽 코테 스터디 38일차 TIL Seat Reservation Manager feat.Heap

https://leetcode.com/problems/seat-reservation-manager/   heap    1.  문제 및 접근    1845. Seat Reservation Manager 3개의 메서드1. SeatManager(int n)의 자리 초기화2. reserve 예약하면 작은 수부터 예약하고, 작은 수 반환3. unreserve 들어온 자석 번호 취소 void O(n)으로 푸니 마지막에 시간초과 걸림  Constraints:1 1 For each call to reserve, it is guaranteed that there will be at least one unreserved seat.For each call to unreserve, it is guaranteed that se..

알고리즘 2024.06.26