文件: root - text - article - 2019 - 11 - minimum-size-subarray-sum.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 475 次阅读, 19406 次搜索 | 81 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 475 次阅读, 19406 次搜索 | 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 次阅读, 19406 次搜索 | 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
猜您喜欢...
- Daily Interview Problem: Validate Binary Search Tree
- Windows Scripting
- Generate All IP Addresses
- [Daily Problem] Validate Balanced Parentheses
- PHP Unit Tests on VPS Server
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Daily Interview Puzzle: Intersection of Linked Lists
- Daily Interview Question: Word Search
- Most Frequent Subtree Sum
- Daily Interview Problem: Arithmetic Binary Tree
©2006~2024 牛排过熟 - 0.0076 秒 - 2650.064 KB/s - 29 在线 内存: 493.33 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)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。