leet code - 149. Max Points on a Line (hard, math)
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. Example 1:Input: points = [[1,1],[2,2],[3,3]]Output: 3Example 2:Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]Output: 4 Constraints:1 points[i].length == 2-104 All the points are unique. points.length = 300 으로 모든 점 쌍에 대해 기울기를 계산..
2025. 4. 20.
leet code - 59. Spiral Matrix II (medium, matrix)
leet code - 59. Spiral Matrix II (medium, matrix)Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3Output: [[1,2,3],[8,9,4],[7,6,5]]Example 2:Input: n = 1Output: [[1]] Constraints:1 n이라는 숫자가 주어지면 n*n 크기의 매트릭스를 생성해나선 순회를 하면서 해당 순서의 숫자로 update def generateMatrix(self, n: int) -> List[List[int]]: x, y, ..
2025. 4. 17.