![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/bC8H9H/btq8dSNWUT2/V4oFkL45Lg4K1YHFQudnV0/img.png)
문제 문자가 주어지면 그 중에서 반복하지 않는 첫번째 문자열 찾는 문제 풀이 1 s = 'aaabcccdeef' from collections import defaultdict # 빈도수 구하기 z = defauldict() for i in s: if z[i]: z[i] +=1 else: z[i] = 1 # Loop defaultdict to find the first for k, v in z.items(): if v ==1: return k 풀이 2 x = 'aaaabbbcddeef' for i in x: if x.find(i) == x.rfind(i): return i str.find() : 가장 작은 인덱스 반환 str.rfind() : 가장 큰 인덱스 반환 built-in function 을 사용..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/D2U1i/btqF5zbGjHM/JrQmWYDDt86ulffwtjCcX1/img.png)
List only def is_palindrom(s: str) -> bool: strs = [] # Using deque for char in s: if char.isalnum(): strs.append(char.lower()) while len(strs) > 1: if strs.pop(0) != strs.pop(): return False return True Using deque from collections import deque def is_palindrom(s: str) -> bool: strs = deque([]) for char in s: if char.isalnum(): strs.append(char.lower()) while len(strs) > 1: if strs.popleft() !=..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/2WQuc/btqE3eS9oFz/HzoucOY4ghlFCD7yPoNJ1K/img.png)
Question Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order, not the kth distinct element. Example matrix = [ [ 1, 5, 9], [10, 11, 13], [12, 13, 15] ], k = 8, return 13. 처음 생각한 간단한 방식은 matrix를 flatten 한 뒤 그 리스트의 k-1번째 인덱스를 리턴하면 될 듯하여 만든 코드입니다. class Soluti..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/xL5m6/btqEGgjDMUE/KdnKuK6gNv0ELi2XoBLVfK/img.jpg)
Question Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Solution class Solution: def searchInsert(self, nums: List[int], target: int) -> int: return 1일1깡 방법 if target in nums: return nums.index(target) else: nums.append(target) nums.sort() return nums.index(target) Binary Search low = 0 hi..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/d19AYD/btqEGBUEqAf/a7t4sQlucGMa7JFKzSReP0/img.jpg)
Problem no.93 Restore IP Address Question: Given a string containing only digits, restore it by returning all possible valid IP address combinations. A valid IP address consists of exactly four integers (each integer is between 0 and 255) separated by single points. Solution: class Solution: def restoreIpAddresses(self, s: str) -> List[str]: l = len(s) if l 4*3: return [] ans = set() ..
- Total
- Today
- Yesterday
- Fine-Tuning
- csv
- palindrome
- Python
- kubernetes context
- go
- 책리뷰
- Container
- Binary
- Shell
- kubens
- AWS
- LLM
- K8S
- 나는리뷰어다
- BASIC
- feed-forward
- lllm
- leetcode
- collator
- Algorithm
- Gemma
- 한빛미디어
- error
- Kubernetes
- 파이썬
- 키보드
- Git
- docker
- book
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |