일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 자연어처리
- Python
- stratascratch
- 슬라이딩윈도우
- Microsoft
- 알고리즘
- dfs
- GenerativeAI
- 투포인터
- 릿코드
- 파이썬기초100제
- 파이썬알고리즘
- 파이썬
- Python3
- tree
- gcp
- 코드업
- slidingwindow
- LeetCode
- codeup
- 리트코드
- 니트코드
- heap
- medium
- two-pointer
- GenAI
- nlp
- sql코테
- SQL
- 생성형AI
- Today
- Total
목록2025/02/26 (6)
Tech for good

https://neetcode.io/problems/longest-repeating-substring-with-replacement NeetCode neetcode.io🛠 해결 방법슬라이딩 윈도우를 사용하여 left와 right 두 개의 포인터로 윈도우 크기를 조정한다.윈도우 내에서 가장 많이 등장한 문자를 찾고, 나머지 문자들을 k번 변경할 수 있는지 확인한다.윈도우 크기에서 가장 많이 등장한 문자 개수를 제외한 나머지 문자가 k보다 크면 left 포인터를 이동하여 윈도우를 줄인다.최대 윈도우 크기를 갱신하면서 탐색을 진행한다.class Solution: def characterReplacement(self, s: str, k: int) -> int: left = 0 m..

// calories = [1,2,3,4,5]// k = 2// lower = 5// upper = 6// 1st: (1,2) = 3 -1// 2nd: (2,3) = 5 -> 0슬라이딩 윈도우 접근법:슬라이딩 윈도우를 사용하면 매번 k 길이의 구간을 합산하는 대신, 윈도우를 한 칸씩 이동하며 기존 합에서 가장 왼쪽 값을 빼고, 새롭게 들어온 값을 더하는 방식으로 효율적으로 합계를 구할 수 있다.시간 복잡도는 O(n)으로, calories 길이가 최대 10^5까지 가능하므로 효율적으로 동작한다.class Solution: def dietPlanPerformance(self, calories: List[int], k: int, lower:int, upper: int) -> int: points = ..

with cte as ( select feature_id, user_id, max(step_reached) as max_step from facebook_product_features_realizations group by feature_id, user_id)select f.feature_id, ifnull(avg(cte.max_step/f.n_steps)*100, 0) avg_percentagefrom facebook_product_features fleft join cte on f.feature_id = cte.feature_idgroup by f.feature_id;

# Solution 1SELECT COUNT(*) AS n_approvedFROM facebook_friendship_requestsWHERE MONTH(date_approved) IN(1,2);# Solution 2SELECT COUNT(*) AS n_approvedFROM facebook_friendship_requestsWHERE date_approved IS NOT NULLAND DATE_FORMAT(date_approved, '%Y-%m') IN ('2019-01', '2019-02');

with cte as ( select day, user1 from facebook_user_interactions union all select day, user2 as user1 from facebook_user_interactions) select day, count(*)/2, count(distinct user1)from ctegroup by day;

# Soltuion 1SELECT ROUND( (SELECT COUNT(*) FROM facebook_messages_received) / (SELECT COUNT(*) FROM facebook_messages_sent), 2 ) AS success_ratio;# Solution 2SELECT (SELECT COUNT(*) FROM facebook.messages.received) / (SELECT COUNT(*) FROM facebook.messages.sent) AS received_to_sent_ratio;