BackmediumUncategorized uncategorized medium

Dual Element Summation Solution

Problem Statement

You are given a sorted array of distinct integers `numbers`. Determine whether there exist two elements in the array that add up to a specified target sum `targetSum`. If such a pair exists, return the indices of these two elements in the array. Otherwise, return an empty array.

Example 1
Input
{"numbers":[2,7,11,15],"targetSum":9}
Output
[0,1]
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free