2021/11 4

leetcode 1026(트리), 1525(two pointer, hashmap), 1884(dp, 계란층문제)

1026 https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/ 어떤 트리에서 자손 관계에서 절대값의 차가 최대가 되어야 한다. 방법론을 생각해보면 현재 노드 아래 자식들중에서의 최대값과 최소값을 알고 있어야 한다. 그래야 abs(현재노드- 자식 최대값), abs(현재노드- 자식 최소값)의 최대값을 구할수있기 때문이다. class Solution: def maxAncestorDiff(self, root: Optional[TreeNode]) -> int: self.ret = 0 def inorder(node): if not node: return 9999999999, -9999999999 l_min, l_max = inorde..

카테고리 없음 2021.11.27

leetcode 2023, 979(트리), 1310(prefix xor)

2023 https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/ 요건 제한조건이 너무 단순해서 그냥 마음가는대로 이중 반복문으로 풀수도있지만 그랬다가는 알고리즘 공부하는 의미가 없다. nums리스트에서 두개만 앞값 + 뒷값으로 문자열을 연결했을때 target이 나오면 된다. prefix, suffix 딕셔너리를 만들어서 풀수 있는데, prefix 딕셔너리에는 앞에서 얼마만큼 만들었는지를 저장하고, suffix 딕셔너리에는 뒤에서 얼마만큼 만들었는지를 저장해둔다. nums = ["123","4","12","34"], target = "1234" 인 경우를 예로 보면 target 1234에 대해서 ..

prometheus + grafana getting started(k8s node monitoring)

모니터링을 위해 설치했던 prometheus와 grafana를 가볍게 재정리합니다. 관리하는 k8s의 노드 리소스 모니터링을 진작 만들었어야 했는데 다른거 하느라 못하다가 시간이 남아서 이번에 추가했다. 모니터링은 prometheus + grafana로 하기로 했다. 1. Prometheus 먼저 prometheus의 아키텍쳐에 대해 알아보자면 https://blog.outsider.ne.kr/1254 요 글이 파악하기에 가장 설명이 잘되어있었다. https://prometheus.io/docs/introduction/overview/ prometheus는 크게 Exporter, Push gateway, Server, Alert manager로 나눌수 있다. - Exporter는 모니터링 대상의 메트릭 ..

data engineering 2021.11.08

mysql simple dump process

1. 걸릴 시간을 대략적으로 체크해보기 위해 테이블의 크기를 확인한다. 참조 : https://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database 아래 쿼리를 돌려본다. 테이블의 크기가 어느정도 큰 경우로 생각해서 gb단위로 출력해본다. mysql> select table_name, round(((data_length + index_length) / 1024 / 1024 / 1024), 2) `size (gb)` \ -> from information_schema.TABLES WHERE TABLE_SCHEMA = "{내 디비}"; +-----------------------------------..

data engineering 2021.11.04