전체 글
-
프로그래머스 - 시저 암호알고리즘 2024. 4. 11. 23:24
class Solution { public String solution(String s, int n) { StringBuilder sb = new StringBuilder(); for(char c : s.toCharArray()) { if(c >= 'a' && c 'z') ? (char)(c - 26 + n) : (char)(c + n); sb.append(c); } else if(c >= 'A' && c 'Z' ? (char)(c - 26 + n) : (char)(c + n); sb.append(c); } else { sb.append(" "); } } return sb.toString(); } } 소문자, 대문자인지 판별 후 n을 더했을 때 범위를 넘어선다면 알파벳의 길이인 26을 빼서 다시 a, A..
-
프로그래머스 - 최빈값 구하기알고리즘 2024. 4. 6. 21:41
import java.util.*; class Solution { public int solution(int[] array) { int answer = 0; int frequency = 0; // 최대 빈도수 boolean overlap = false; // 중복여부 Map map = new HashMap(); for(int num : array) { if(!map.containsKey(num)) map.put(num, 1); else { int cnt = map.get(num); map.put(num, cnt + 1); } } for(int key : map.keySet()) { if(frequency == map.get(key)) overlap = true; if(frequency < map.get(..
-
프로그래머스 - 안전지대알고리즘 2024. 4. 5. 20:54
class Solution { public int solution(int[][] board) { int answer = 0; for(int i = 0; i < board.length; i++) { for(int j = 0; j < board.length; j++) { if(board[i][j] == 1) danger(board, i, j); } } for(int i = 0; i < board.length; i++) { for(int j = 0; j < board.length; j++) { if(board[i][j] == 0) answer++; } } return answer; } public void danger(int[][] board, int x, int y) { for(int i = -1; i
-
프로그래머스 - 다항식 더하기알고리즘 2024. 4. 5. 01:29
import java.util.*; class Solution { public String solution(String polynomial) { StringBuilder sb = new StringBuilder(); int var = 0; int con = 0; List variables = new ArrayList(); List constants = new ArrayList(); for(String s : polynomial.split(" ")) { if(s.contains("x")) { s = s.replace("x", ""); if(s.equals("")) variables.add(1); else variables.add(Integer.parseInt(s)); } else if(s.contains(..
-
Github Actions Build 에러트러블슈팅 2024. 3. 15. 09:08
원인 Github으로 CI를 진행하는 과정에서 빌드가 되지 않는 문제. 아래와 같은 오류가 발생. import org.hh99.tmomi.global.exception.GlobalException; ^ > Task :tmomi-consumer:compileJava FAILED /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/util/ReservationQueue.java:7: error: package org.hh99.tmomi.global.exception.message does not exist import org.hh99.tmomi.global.exceptio..
-
대용량 데이터 생성 후 저장, OutOfMemoryError트러블슈팅 2024. 3. 15. 07:26
원인 행사장의 좌석의 수(3,000,000)만큼 데이터 생성 시 , java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "http-nio-5000-Acceptor” 가 발생. [ 데이터 생성 코드 ] @Transactional public void createEventTimes(EventTimesRequestDto eventTimesRequestDto, Long eventId) { Event event = eventRepository.findById(eventId) .orElseThrow(() -> new GlobalException(HttpStatus.NOT_FOUND, ExceptionCode.NOT_EXIST_E..
-
Redis Repository를 사용했을 때 ttl이 끝나도 모두 삭제되지 않는 에러트러블슈팅 2024. 2. 22. 04:01
@Id값만 TTL로 사라지고 그 외에는 남아있는 문제가 발생 Redis Repository Hash말고 Set도 저장이 됨 기본적으로 @RedisHash에서 @Id 어노테이션이 적용된 key에 대해서만 ttl 기능이 동작한 @RedisHash를 통한 RedisRepository 방식에서는 Set에서 secondary index 데이터를 삽입 및 제거하며 index를 유지 관리하는데, 이때 index 정리가 수행되기 위해서는 keyspace events가 탐지되어야 하며, keyspace events에 대한 설정이 되어 있어야 한다고 합니다. 이를 해결하기 위해 @EnableRedisRepositories(enableKeyspaceEvents = RedisKeyValueAdapter.EnableKeyspa..