From cacf0a999ca2975b99c3a3ec29b7f19295fe636f Mon Sep 17 00:00:00 2001 From: rimogsu Date: Thu, 19 Nov 2026 22:50:56 +0900 Subject: [PATCH] 1802,1828 --- ...ue at a Given Index in a Bounded Array.py" | 31 +++++++++++++++++++ ...es on Number of Points Inside a Circle.py" | 21 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v4/1802. Maximum Value at a Given Index in a Bounded Array.py" create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v4/1828. Queries on Number of Points Inside a Circle.py" diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1802. Maximum Value at a Given Index in a Bounded Array.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1802. Maximum Value at a Given Index in a Bounded Array.py" new file mode 100644 index 00000000..529abd6e --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1802. Maximum Value at a Given Index in a Bounded Array.py" @@ -0,0 +1,31 @@ +''' +Time Limit Exceeded +53 / 370 testcases passed +''' +class Solution: + def maxValue(self, n: int, index: int, maxSum: int) -> int: + x=1 + cap_left = index + cap_right = n-index-1 + left = 0 + right = 0 + left_sum = 0 + right_sum = 0 + _sum = 0 + while True: + # print(x,left,right, left_sum, right_sum, _sum) + if x >=3 and cap_left > left: + left += 1 + if x >=3 and cap_right > right: + right += 1 + left_sum += left + right_sum += right + _sum = left_sum + right_sum + n + x - 1 + x+=1 + if _sum > maxSum: + break + + return x -2 + + + \ No newline at end of file diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1828. Queries on Number of Points Inside a Circle.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1828. Queries on Number of Points Inside a Circle.py" new file mode 100644 index 00000000..abe46cc7 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1828. Queries on Number of Points Inside a Circle.py" @@ -0,0 +1,21 @@ +''' +1. 아이디어 : +원과 가까운지 체크 + +2. 시간복잡도 : +o(n*m) (정렬) + +3. 자료구조/알고리즘 : +''' + +class Solution: + def countPoints(self, points: list[list[int]], queries: list[list[int]]) -> list[int]: + lst = [] + for x1,y1,r in queries: + tmp = 0 + for x2,y2 in points: + if (x2 - x1)**2 + (y2 - y1)**2 <= r**2: + # print(x1,y1,x2,y2,r,(x2 - x1)^2 + (y2 - y1)^2) + tmp += 1 + lst.append(tmp) + return lst \ No newline at end of file