Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a method to find all pairs in an array that sum up to a given value.

Medium

Problem Statement

Write a method to find all pairs in an array that sum up to a given value.

Sample Input

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

Sample Output

[[2, 4], [1, 5]]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined array and target sum array = [1, 2, 3, 4, 5] target_sum = 6 # Your logic here
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [1, 2, 3, 4, 5], Sum: 6
Expected Output
[[2, 4], [1, 5]]