본문 바로가기

투포인터16

[leetcode 15] 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Notice that the solution set must not contain duplicate triplets. two sum 진화문제. 3개의 숫자를 합해서 0이 되는 조합을 찾는다. Example 1: Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Example 2: Input: nums = [] Output: [] Example 3: Input: n.. 2020. 10. 14.
[leetcode 11] Container With Most Water Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container. 최대로 채울 수 있는 물의 양을 구하기 Example 1: Input: h.. 2020. 10. 14.
[leetcode 1234]Replace the Substring for Balanced String You are given a string containing only 4 kinds of characters 'Q', 'W', 'E' and 'R'. A string is said to be balanced if each of its characters appears n/4 times where n is the length of the string. Return the minimum length of the substring that can be replaced with any other string of the same length to make the original string s balanced. Return 0 if the string is already balanced. Example 1: I.. 2020. 10. 1.
[leetcode 986] Interval List Intersections Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order. Return the intersection of these two interval lists. (Formally, a closed interval [a, b] (with a 2020. 9. 30.