Skip to content
CampusEduX

Find a Subarray with Given Sum

Mediumjavapythonccppjavascript

Given an array of non-negative integers and a target sum, determine whether some contiguous subarray adds up to exactly that sum.

Input Format

The first line contains two integers N and target. The second line contains N space-separated non-negative integers.

Output Format

Print 1 if such a subarray exists, otherwise print 0.

Related Problems

  • Find the Majority Element
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Rotate an Array by K Positions
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Maximum Subarray Sum
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...