File: root - text - article - 2019 - 11 - minimum-size-subarray-sum.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 396 Views, 18094 Search Bots | 81 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 396 Views, 18094 Search Bots | 81 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Amazon:
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.
Example:
Input: s = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: the subarray [4,3] has the minimal length under the problem constraint.
Here is the method signature:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 396 Views, 18094 Search Bots | 81 Words 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.
Example:
Input: s = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: the subarray [4,3] has the minimal length under the problem constraint.
Here is the method signature:
class Solution:
def minSubArrayLen(self, nums, s):
# Fill this in
print Solution().minSubArrayLen([2, 3, 1, 2, 4, 3], 7)
# 2
Related Articles
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem: Running Median
- Find the non-duplicate number
- Number of Ways to Climb Stairs
- Algorithm Interview: Permutations of numbers
- [Daily Problem] Course Prerequisites
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Spectrum Master
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Maximum In A Stack
©2006~2024 SteakOverCooked - 0.01081 Seconds(s) - 5018.075 KB/s - 80 Online Memory: 516.42 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !