minimum-window-substring

做法的话 用two pointers和hashmap

Given a list of 2d points, if any two points have distance(straight line) <= k , group them together. For example. [P1,P2,P3], P1 to P2 <=k, P2 to p3<=k, p1 to p3>k. they are still in the same group. (distance relationship is chainable ) ask how many groups can you find ? I can think of N^2 time complexity with union and find. but how to do better than that? maybe NlogN or O(N)?

Find the maximum sum possible by adding numbers in list together. You can add at most k numbers, must select from left or right.

Example:

[2, 3, 5, 7, 1] K = 3

max sum is [1 7 5] = 13

[5, 10, 2, 9, 11] K = 3

max sum is [5 10 11] = 26

select from left 5, 10

from right 11

Follow Up, another list length K

Example [2, 3, 5, 7, 1]

the first element we select from the original list times 2

second times 3

third times 5

get maximum value