Home
Deercode
Cancel

[Leet Code풀이] 413. Arithmetic Slices

문제 설명 https://leetcode.com/problems/arithmetic-slices/ arithmetic slice란 1,2,3,4 또는 -1, -3, -5 -7 처럼 같은 간격으로 3개 이상 이어진 숫자열을 의미한다. 일종의 Dynamic programming 문제인데, 규칙을 보면 아래와 같다. 1) 최대 arithmetic sli...

[Linux] Installation, Usage and Commands of tmux

tmux tmux stands for Terminal Multiplexer. When using Linux in the terminal, there can be inconvenience when sessions are disconnected, causing processes in progress to be interrupted or work to be...

[Linux] xargs command and usage example

Why use the xargs command? I wanted to utilize the output from certain commands to perform new commands in bulk. The xargs command has the ability to read a data stream and generate and execute a...

Haproxy

HA Proxy란 하드웨어 방식의 스위치의 기능을 대체하는 소프트웨어 로드 밸런서로 L4(TCP, UDP), L7(HTTP/HTTPS) 기능 및 로드 밸런싱 기능을 제공한다. 설치가 쉽고 빠르며 서비스 이중화(HA, High Availability)를 제공한다. 로드밸런싱이 왜 필요한가? 서버에 요청하는 클라이언트의 수가 많아지면 요청에 대한 응답을...

[Leet Code풀이] 90. Subsets 2

문제 설명 https://leetcode.com/problems/subsets-ii/ 주어진 리스트로 부터 가능한 모든 부분 집합을 구하는 문제다. 다만 입력에 중복값이 있기 때문에 출력 값에서도 이를 잘 처리해 주어야 한다. Subset 문제 문제에 추가적인 처리를 해주었는데, 먼저 [4,4,4,1], [4,1,4,4] 와 같은 처리를 위해...

[Leet Code풀이] 78. Subsets

문제 설명 https://leetcode.com/problems/subsets/ 주어진 리스트로 부터 가능한 모든 부분 집합을 구하는 문제다. DFS를 이용해 생성되는 경우의 수를 모두 구했다. 파이썬 알고리즘 인터뷰 책을 읽고 푼 문제라 코드가 같다. 풀이 class Solution: def subsets(self, nums: List[...

[Leet Code풀이] 117.Populating Next Right Pointers in Each Node II

문제 설명 https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ 자세한 문제 설명은 위 링크 참고. 이진 트리의 각 노드의 next를 모두 오른쪽에 있는 노드를 가리키도록 변경하는 문제다. BFS를 적용하면 적어도 같은 레벨에 있는 노드에 대해서는 오른쪽 노드를 ...

[Leet Code풀이] 1091. Shortest Path in Binary Matrix

문제 설명 https://leetcode.com/problems/shortest-path-in-binary-matrix BFS는 이론적으로 가장 가까운 노드부터 순차적으로 탐색하기 때문에 간선(Edge)에 가중치(weight)가 없는 그래프에 한해 Shotest path를 찾을 수 있다. 필자는 일단 기본적인 BFS 탐색 알고리즘을 알고 있었지만 해...

[Leet Code풀이] 713. Subarray Product Less Than K

문제 설명 https://leetcode.com/problems/subarray-product-less-than-k/ 자세한 문제는 위 링크 참고. 리스트에 숫자가 주어지면, k 보다 작은 수열을 찾는 문제다. 답을 찾는건 쉬우나, time out 에러를 해결하려면 결국 two pointer로 해결해야 한다. 첫번째 풀이 (타임아웃 에러) 첫번째...

[Leet Code풀이] 438. Find All Anagrams in a String

문제 설명 https://leetcode.com/problems/find-all-anagrams-in-a-string/ 자세한 문제는 위 링크 참고. 대상 문자열 s가 주어지면, p 문자열의 애니어그램에 해당하는 부분의 시작 인덱스를 리턴하는 문제다. 여기서 애니어 그램이란 p가 “abc”라고 되어 있을때 abc, acb, bac, bca, cab,...