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 | 476 Views, 19498 Search Bots | 81 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 476 Views, 19498 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 | 476 Views, 19498 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
- Daily Interview Problem: Buddy Strings
- Algorithm Interview: Subarray With Target Sum
- Daily Interview Problem: Room scheduling
- Staying on a Chess Board
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Find Pythagorean Triplets
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Daily Interview Problem: Spiral Traversal of Grid
- Progess made
©2006~2024 SteakOverCooked - 0.00816 Seconds(s) - 2376.302 KB/s - 24 Online Memory: 492.52 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="index, 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 !