array

[Leetcode 560] Subarray Sum Equals K

Question Leetcode 560: Subarray Sum Equals K Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Note: The length of the array is in range [1, 20,000]. The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7]. Examples Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Solution Method 1 (TLE) 我一开始想到的解法是使用一个存了dict的array,记录下每个位置上出现的所有可能的sum的数量。这样进行到每一位的时候只需要看一下他前面那个位置的dict,就能得到包含当前位置数字所有可能出现的sum。

[Leetcode 807] Max Increase to Keep City Skyline

Question Leetcode 807: Max Increase to Keep City Skyline In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can be different for different buildings). Height 0 is considered to be a building as well. At the end, the “skyline” when viewed from all four directions of the grid, i.

[Leetcode 683] K Empty Slots

Question Leetcode 683: K Empty Slots There is a garden with N slots. In each slot, there is a flower. The N flowers will bloom one by one inN days. In each day, there will be exactly one flower blooming and it will be in the status of blooming since then. Given an array flowers consists of number from 1 to N. Each number in the array represents the place where the flower will open in that day.

Video Stitching

This is a question from leetcode.com. Problem Question You are given a series of video clips from a sporting event that lasted T seconds. These video clips can be overlapping with each other and have varied lengths. Each video clip clips[i] is an interval: it starts at time clips[i][0] and ends at time clips[i][1]. We can cut these clips into segments freely: for example, a clip [0, 7] can be cut into segments [0, 1] + [1, 3] + [3, 7].