文件: root - text - article - 2019 - 11 - minimum-size-subarray-sum.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 475 次阅读, 19401 次搜索 | 81 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 475 次阅读, 19401 次搜索 | 81 个单词
| 浏览 | 博客存档
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:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 475 次阅读, 19401 次搜索 | 81 个单词 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
猜您喜欢...
- 56 Bytes
- [Daily Problem] Remove k-th Last Element From Linked List
- Daily Interview Problem: Running Median
- [Daily Problem] Move Zeros
- Algorithm Interview: No Adjacent Repeating Characters
- Detect Linked List Cycle
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Sorting a list with 3 unique numbers
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Reverse a Linked List
©2006~2024 牛排过熟 - 0.01189 秒 - 1617.232 KB/s - 41 在线 内存: 491.41 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。