leetcode主要算法

1尺取法,针对孤陋寡闻的我而言,做题以前没听说过,之后了解了一下这个方式,觉得许多题目都能够用这个方法解决,在leetcode上有一类题称为Two Pointers,其中一部分题目就应当应用尺取法来解决。

2在介绍尺取法的应用以前,先看一个典型的案例Leetcode209. Minimum Size Subarray Sum:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous 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] and s = 7,the subarray [4,3] has the minimal length under the problem constraint.

- END -

阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。