617. Merge Two Binary Trees
·
Algorithm
Merge Two Binary Trees - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 나의 Trash Garbage 코드 class Solution: def search(self, p1, p2): p1.val += (p2.val if p2 else 0) if p1.left: if p2: self.search(p1.left, p2.left) else: self.search(p1.left, TreeNode(0, None, None)) else: if p2..
14. Longest Common Prefix
·
Algorithm
Longest Common Prefix - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 완전 탐색 from typing import * class Solution: def sol(self, strs, length): if length == 0: return True for strr in strs: # length 보다 문자열이 짧은 상황은 불가능하니깐 반환 if len(strr) < length: return False if strs[0][:length]..
424. Longest Repeating Character Replacement
·
Algorithm
Longest Repeating Character Replacement - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 삽질 1 (실패) from typing import * from collections import defaultdict # 주어진 문자열에서 지정된 횟수만큼 알파벳을 교환했을 때 # 동일한 문자로 구성된 부분 문자열의 길이의 최댓값을 반환하시오 class Solution: def characterReplacement(self, s: str, ..
2174번: 로봇 시뮬레이션
·
Algorithm
1. 소스 코드 import sys from collections import deque r = sys.stdin.readline width, height = map(int, r().split()) robot_num, command_num = map(int, r().split()) board = [[0] * width for _ in range(height)] robots = {} for i in range(robot_num): y, x, direction = r().split() ny = int(y) - 1 nx = height - int(x) robots[i + 1] = [nx, ny, direction] board[nx][ny] = i + 1 commands = [] for i in range(co..
7. Reverse Integer
·
Algorithm
Reverse Integer - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 내 풀이 class Solution: def reverse(self, x: int) -> int: x = int(str(x)[::-1]) if str(x)[-1] != "-" else int("-" + str(x)[::-1][:-1]) return x if abs(x) < 2 ** 31 else 0
M1 맥북에서 Docker + Tomcat 이미지 사용하기
·
Programming
M1 Docker가 정식 Release 되었다. 열심히 삽질해서 Tomcat 이미지에 HTML 파일을 올려서 접속하는 것을 성공했다. GUI 환경도 잘 되어있어서 가능하지만 이미지 검색할 때 회원가입을 해야 하는 귀찮음(?)때문에 전통적인 CLI방식으로 테스트해봤다. Docker Desktop for Apple silicon docs.docker.com 1. Docker 설치 이 부분은 기존의 맥 애플리케이션 설치할 때와 동일하게 진행하면 된다. 설치 후에 Docker의 아키텍처가 Apple인 것을 확인한다. Intel이라고 뜨면 M1용을 설치한 것이 아니니깐 주의. 2. Tomcat 이미지 파일 검색 및 다운로드 // docker hub의 tomcat 관련 이미지를 검색 docker search tom..