일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 이코테
- Algorithm
- C++
- 리액트
- 매일메일
- react
- 항해99
- programmers
- maeil-mail
- redux-saga
- react-router
- sw expert academy
- createSlice
- Get
- axios
- react-redux
- 항해플러스
- 코딩테스트합격자되기
- json-server
- redux
- Python
- SW
- 테코테코
- JavaScript
- java
- 알고리즘
- 프로그래머스
- 자바
- redux-toolkit
- useDispatch
- Today
- Total
목록Python (143)
Binary Journey
** Python def solution(s): tmp_s = s answer = 0 if len(s) % 2 == 1: return answer for i in range(len(s)): tmp_list = [] for t in tmp_s: if t in "({[": tmp_list.append(t) elif t == ")" and len(tmp_list) > 0 and tmp_list[-1] == "(": tmp_list.pop() elif t == "}" and len(tmp_list) > 0 and tmp_list[-1] == "{": tmp_list.pop() elif t == "]" and len(tmp_list) > 0 and tmp_list[-1] == "[": tmp_list.pop() ..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Python Christopher 님의 도움을 받음 def solution(skill, skill_trees): answer = 0 for skill_tree in skill_trees: skill_t = [ s for s in skill_tree if s in skill] skt = ''.join(skill_t) if skill.find(skt) == 0: answer += 1 return answer
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 월간코드챌린지 때 효율성에서 막혀서 결국 못 풀었는데 풀이 보고 너무나도 간단해서 놀랐다. 1차원 배열을 n 으로 나눈 몫, 나머지에서 max 값만 구하면 되다니.. ** python def solution(n, left, right): answer = [] for i in range(left, right + 1): answer.append(max(divmod(i, n)) + 1) return answer 참고: https://sangsangss.tistory.com/197 [프로그래머스] n^2 배열 자르기 https://programmers.co.kr/learn/courses/30/le..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Python 코드 실행에서는 통과됐는데 채점에서 35퍼 나와서 뭐가 문제인가 했는데 질문하기에 방향성이 없어야 한다는 말에 깨달음 (1,1) -> (0,1) 이랑 (0,1) -> (1,1) 은 같은 길을 갔으므로 카운트 되면 안됨 def solution(dirs): answer = 0 loc = [0, 0] strd = {'U': (0, 1), 'D': (0, -1), 'R': (1, 0), 'L': (-1, 0)} visited = set() for d in dirs: old_x = loc[0] old_y = loc[1] new_x = loc[0] + strd[d][0] new_y ..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Python 1) 1차 시도 (실패 73.3/100) from datetime import timedelta def replace_melody(melody): return melody\ .replace('C#', 'Z')\ .replace('D#', 'Y')\ .replace('F#', 'X')\ .replace('G#', 'W')\ .replace('A#', 'V') def cal_time_diff(start, end): start_hour, start_min = map(int, start.split(":")) start_time = timedelta(hours=start_hour,..
* 상하좌우 n = int(input()) a = input().split() _dict = { 'R': (0, 1), 'L': (0. -1), 'U': (-1, 0), 'D': (1, 0) } location_v = 1 location_h = 1 while a: direction = a.pop(0) if direction == 'R' and location_h == n: pass elif direction == 'L' and location_h == 1: pass elif direction == 'U' and location_v == 1: pass elif direction == 'D' and location_v == n: pass else: location_v += _dict[direction][0]..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges import re def solution(files): reg = [re.split(r'(\d+)', s) for s in files] reg.sort(key = lambda x: (x[0].lower(), int(x[1]))) return [''.join(s) for s in reg] 참고: https://velog.io/@sem/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-LEVEL2-%ED%8C%8C%EC%9D%BC%EB%AA%85-%EC%A0%95%EB%A0%AC-Python [프로그래머스] LEVEL2 파일명 정렬 (Python..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges level 2 너무 어렵다,, def solution(msg): dic = {} for i in range(26): dic[chr(65+i)] = i+1 w = 0 c = 0 answer = [] while True: c += 1 if len(msg) == c: answer.append(dic[msg[w:c]]) break if msg[w:c+1] not in dic: dic[msg[w:c+1]] = len(dic) + 1 answer.append(dic[msg[w:c]]) w = c return answer 참고: https://hazung.tistory.com/89 [알고리즘] 프로그래..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges def solution(board): for i in range(1, len(board)): for j in range(1, len(board[i])): if board[i][j] == 1: board[i][j] = min(board[i-1][j-1], board[i-1][j], board[i][j-1]) + 1 # print(board) answer = 0 for b in board: lmax = max(b) answer = max(answer, lmax) return answer**2 참고: https://velog.io/@ju_h2/Python-%ED%94%84%EB%A1%9C%EA%..
강의 듣다가 필요한 부분은 메모를 하려 한다. * 그리디 알고리즘에서 본 식인데 처음에 생각한 식이 모든 수를 탐색해서 -1을 한 뒤 결과를 도출해내는 방식이었다. 근데 그러면 시간 복잡도가 O(K) 인데 시간복잡도를 O(logK) 로 바꿀 수 있는 식이라 해서 메모한다. (target 은 n을 k로 나눈 몫 * k 로 나머지 없는 수다.) n, k = map(int, input().split()) result = 0 while n >= k: target = (n // k) * k result += (n - target) n = target result += 1 n //= k result += (n - 1) print(result) * 곱하기 혹은 더하기 data = map(int, str(input()..