Skip to content
CampusEduX

Two Sum in Sorted Array

Easyjavapythonccppjavascript

Given a sorted array and a target value, determine whether two elements at different positions add up to the target, using the two-pointer technique.

Input Format

The first line contains two integers N and target. The second line contains N space-separated integers in non-decreasing order.

Output Format

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

Related Problems

  • Remove Duplicates Using Two Pointers
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Maximum Sum of K Consecutive Elements
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • First Negative Number in Every Window
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...