Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Optimized Algorithm Problem Solving
00:00
5 left

Optimized Algorithm Problem Solving

MediumPython

Problem

Can you solve this algorithmic problem using an optimized approach?

Implement min_subarray_len(nums, target) to return the minimum length of a contiguous subarray whose sum is at least target. All values in nums are positive integers; return 0 if no qualifying subarray exists.

Input: a list of positive integers and a positive integer target. Output: an integer representing the minimum qualifying length.

Constraints

  • 1 <= nums.length <= 1000
  • 1 <= nums[i] <= 100000
  • 1 <= target <= 1000000000

Function Signature

def min_subarray_len(nums, target):
Interviewer

Your question is Optimized Algorithm Problem Solving. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.