2024/12/17 4

Bits: 190. Reverse Bits

190. Reverse Bits https://youtu.be/UcoN6UjAI64?si=QcqwmCh09NAZbJMq class Solution: def reverseBits(self, n: int) -> int: # 1과 & 오퍼레이션하면, 해당 비트 나옴 # > i): n을 i만큼 오른쪽으로 쉬프트하면 i번째 비트가 오른쪽 끝에 위치함 # & 1: AND 연산을 통해 해당 비트를 추출 (나머지는 0) bit = (n >> i) & 1 # 추출한 비트를 뒤집은 위치로 이동 (왼쪽에서부터 채우기) # 31-i: 0번째 비트는 31번째에, 1번째 비트는 30번째에 위치하게 됨 ..

Graphs (싸이클탐지): 210. Course Schedule II★★★

210. Course Schedule II Hint 1 This problem is equivalent to finding the topological order in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses.  Hint 2 Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Hint 3 Topological sort could also be done vi..