[백준 2015] 수들의 합 4
www.acmicpc.net/problem/2015 2015번: 수들의 합 4 첫째 줄에 정수 N과 K가 주어진다. (1 ≤ N ≤ 200,000, |K| ≤ 2,000,000,000) N과 K 사이에는 빈칸이 하나 있다. 둘째 줄에는 배열 A를 이루는 N개의 정수가 빈 칸을 사이에 두고 A[1], A[2], ..., A[N]의 순서로 www.acmicpc.net 누적합과 구간합을 알아야 하는 문제이다. 가끔 보이는 유형인데 볼 때마다 못 푼다...ㅠㅠㅠ eazymean.tistory.com/43 [알고리즘] Prefix Sum 구간 합/누적 합 알고리즘 prefix sum이란 구간 합을 의미한다. 예를 들어, int arr[5] = {10,20,30,40,50}; prefix sum은 prefix[i]..
2021. 1. 1.
[leetcode 454] 4Sum II
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the range of -228 to 228 - 1 and the result is guaranteed to be at most 231 - 1. Example: Input: A = [ 1, 2] B = [-2,-1] C = [-1, 2] D = [ 0, 2] Output: ..
2020. 11. 14.
[leetcode 49] Group Anagrams
Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["bat"],["nat","tan"],["ate","eat","tea"]] Example 2: Input: strs = [""] O..
2020. 10. 30.