Programming Exercises

Create a component that calculates all pairs in a hardcoded array whose sum equals a hardcoded target value.

Hard

Problem Statement

Create a component that calculates all pairs in a hardcoded array whose sum equals a hardcoded target value.

Sample Input

Array: [1, 2, 3, 4, 5]
 Target: 6

Sample Output

Pairs: [[1, 5], [2, 4]]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React from "react"; const PairSum = () => { return ( <div> {/* Display pairs */} </div> ); }; export default PairSum;
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [1, 2, 3, 4, 5]
 Target: 6
Expected Output
Pairs: [[1, 5], [2, 4]]