一:Minimum Size Subarray Sum(最小长度子数组的和O(N)) 题目: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead. For example, given the array [2,3,1,2,4,3…
11. Container With Most Water 题意:取两根求最大体积 思路:使用两个指针分别指向头和尾,然后考虑左右两根: 对于小的那根,如果选择了它,那么能够产生的最大体积一定是当前的情况:因为当前情况体积=这根长度 * 当前距离,以后的话长度一定是左右边界的min,即<=这根长度,距离一定越来越小 因此小的那根以后就不会被选了,因此把小的那根的指针挪动一下 直到指针相遇 class Solution { public: int maxArea(vector<int>&a…
题目描述: Binary Tree Zigzag Level Order Traversal AC Rate: 399/1474 My Submissions Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).…
JavaScript /** * @param {number[][]} matrix * @return {number[]} */ var findDiagonalOrder = function(matrix) { if(matrix == []) return [] let m = matrix.length let n = matrix[0].length let i=0,j=0 let arr = [] for(let l = 0;l<m*n;l++){ arr.push(matri…