목록부분합 (25)
넘치게 채우기
https://leetcode.com/problems/product-of-the-last-k-numbers/description/Product of the Last K Numbers문제 유형: 부분합, 슬라이딩 윈도우문제 난이도: Medium 문제Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream.Implement the ProductOfNumbers class:ProductOfNumbers() Initializes the object with an empty stream.void add(int num) Appends the integer num t..

https://codeforces.com/contest/2063/problem/DCodeforces Round 1000(Div. 2) - D. Game With Triangles문제 유형: 그리디, 수학, 기하학, 삼분 탐색, 구현, 투 포인터, 브루트 포스, 부분합, 구간합시간 제한: 2초메모리 제한: 256MB 문제There are n+m">n+m distinct points (a1,0),(a2,0),…,(an,0),(b1,2),(b2,2),…,(bm,2)">(a1,0),(a2,0),…,(an,0),(b1,2),(b2,2),…,(bm,2) on the plane. Initially, your score is 0">0. To increase your score, you can ..

https://leetcode.com/problems/grid-game/description/leetcode - Grid Game문제 유형: 부분합, 구간합, 그리디문제 난이도: Medium 문제You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((..
https://codeforces.com/contest/2043/problem/CEducational Codeforces Round 173(Div.2) - C. Sums on Segments문제 유형: 수학, 부분합, 그리디시간 제한: 1초메모리 제한: 256MB 문제You are given an array a">a of n">n integers, where all elements except for at most one are equal to −1">−1 or 1">1. The remaining element x">x satisfies −109≤x≤109">−10^9≤x≤10^9.Find all possible sums of subarrays of a"..
https://leetcode.com/problems/count-vowel-strings-in-ranges/description/leetcode - Count Vowel Strings in Ranges문제 유형: 문자열 처리, 부분합문제 난이도: Medium 문제You are given a 0-indexed array of strings words and a 2D array of integers queries.Each query queries[i] = [li, ri] asks us to find the number of strings present in the range li to ri (both inclusive) of words that start and end with a vowel.Return a..
https://www.acmicpc.net/problem/2143BOJ - 두 배열의 합문제 유형: 이진 탐색, 부분합, 정렬문제 난이도: Gold III시간 제한: 2초메모리 제한: 64MB 문제한 배열 A[1], A[2], …, A[n]에 대해서, 부 배열은 A[i], A[i+1], …, A[j-1], A[j] (단, 1 ≤ i ≤ j ≤ n)을 말한다. 이러한 부 배열의 합은 A[i]+…+A[j]를 의미한다. 각 원소가 정수인 두 배열 A[1], …, A[n]과 B[1], …, B[m]이 주어졌을 때, A의 부 배열의 합에 B의 부 배열의 합을 더해서 T가 되는 모든 부 배열 쌍의 개수를 구하는 프로그램을 작성하시오.예를 들어 A = {1, 3, 1, 2}, B = {1, 3, 2}, T=5인 경우..
https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/description/leetcode - Maximum Sum of 3 Non-Overlapping Subarrays문제 유형: 슬라이딩 윈도우, 부분합, 다이나믹 프로그래밍문제 난이도: Hard 문제Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them.Return the result as a list of indices representing the starting position of each int..
https://www.acmicpc.net/problem/1806BOJ - 부분합문제 유형: 부분합, 투 포인터, 슬라이딩 윈도우문제 난이도: Gold IV시간 제한: 0.5초메모리 제한: 128MB 문제10,000 이하의 자연수로 이루어진 길이 N짜리 수열이 주어진다. 이 수열에서 연속된 수들의 부분합 중에 그 합이 S 이상이 되는 것 중, 가장 짧은 것의 길이를 구하는 프로그램을 작성하시오. 입력첫째 줄에 N (10 ≤ N 출력첫째 줄에 구하고자 하는 최소의 길이를 출력한다. 만일 그러한 합을 만드는 것이 불가능하다면 0을 출력하면 된다. 풀이슬라이딩 윈도우를 이용하면 된다.매번 right를 더해줄 때마다, left쪽에서 뺄 수 있는만큼 빼본다.right를 한칸 밀면, left쪽에서는 sum이상인동..
https://leetcode.com/problems/maximum-number-of-k-divisible-components/description/leetcode - Maximum Number of K-Divisible Components문제 유형: 트리, dfs, 부분합문제 난이도: Hard 문제There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the t..
https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/description/?envType=daily-question&envId=2024-11-17leetcode - Shortest Subarray with Sum at Least K문제 유형: 슬라이딩 윈도우, 부분합, 모노토닉 데크문제 난이도: Hard 문제Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.A subarray is..