분류 전체보기

    Auto Commit 오해

    Auto Commit 오해

    글을 쓰게 된 계기 다른 팀원의 auto commit에 관한 발표를 듣고 궁금한 점이 생겼다. Application 단에서, hikariCP의 auto commit 설정을 false로 하면, 디비에 요청시에, auto commit을 set하는 쿼리들이 날아가지 더 이상 날라가지 않아, DB 부하를 줄일 수 있고, DB 커넥션을 얻는 시간을 지연 시켜, 자원을 효율적으로 사용할 수 있다는 발표였다. 여기서 나는 궁금증이 생겼다. HikcariCP의 auto commit 설정을 false로 하면, 트랜잭션의 auto commit 설정은 DB의 설정을 따라갈 것이다. 그래서, 우리 회사의 경우에는 auto commit이 true로 되어 있기에, 해당 transaction의 auto commit이 true가 설..

    [프로그래머스] 미로 탈출 [python]

    [프로그래머스] 미로 탈출 [python]

    문제 bfs로 풀면되는 문제이다. 출발점-> 레버 + 레버 -> 도착점 두 합의 최소를 구하면 된다. 코드 from collections import deque def solution(maps): answer = 0 startDot, leverDot, endDot = None, None, None for i in range(len(maps)): for j in range(len(maps[i])): if maps[i][j] == "S": startDot = (i,j) elif maps[i][j] == "L": leverDot = (i,j) elif maps[i][j] == "E": endDot = (i,j) else: continue startToLever = bfs(maps,startDot, leverD..

    [프로그래머스] 혼자 놀기의 달인 [python]

    [프로그래머스] 혼자 놀기의 달인 [python]

    문제 결국 풀어여 되는 건 간단한데, 문제가 너무 장황하다. dfs로 사이클이 있는 그래프를 찾고, 그래프의 노드의 수가 많은 것들을 곱하면 되는 문제이다. dfs로 그래프들을 모두 구한 후, sort를 하고 가장 큰 두 개를 골랐다. 그래프가 하나만 있을 수도 있기 때문에, 미리 0을 넣어서 무조건 두 개의 그래프가 생길 수 있도록 하였다. 코드 def solution(cards): global cnt answers = [0] isChecked = [False for i in range(len(cards) + 1)] for i in range(1,len(cards) + 1): cnt = 1 if isChecked[i] == False: isChecked[i] = True dfs(cards, i, isC..

    [프로그래머스] 후보키 [python]

    [프로그래머스] 후보키 [python]

    문제 조합과 구현을 섞어 놓은 문제였다. 구현을 잘 한다면 풀 수 있는 문제이다. 코드 def solution(relation): global answer answer = 0 candidates = [] for i in range(1,len(relation[0]) + 1): ## 조합 combination([], i, 0, relation, candidates) return len(candidates) def combination(comb, maxLen, nextN, relation, candidates): global answer if isInCandidates(comb, candidates): return if maxLen == len(comb): if canUseCandidateKey(comb, r..

    [프로그래머스] 문자열 압축 [python]

    [프로그래머스] 문자열 압축 [python]

    문제 https://school.programmers.co.kr/learn/courses/30/lessons/60057 최대 길이가 1000이기 때문에, 완전 탐색이 가능해 완전 탐색으로 문제를 풀었다. 길이가 1부터 Input의 길이까지 앞에서부터 자르도록 해서, 가장 짧은 문자열을 찾았다. O(n^2) 코드 def solution(s): answer = 100000 if len(s) == 1: return 1 for i in range(1, len(s)): j = 0 cnt = 0 before = s[j:i+j] tmp = "" while j + i len(s): tmp += s[j:] answer = min(answer, len(tmp)) return answer """ aabbacc -> 2a2b..