Menu
Coddy logo textTech

K-Pair (warm-up)

Lesson 1 of 3 in Coddy's Interview Coding Challenges - Pack IV course.

challenge icon

Challenge

Easy

Write a function findPair which gets an array of integers arr and a target number k and returns true if there are a pair of integers in arr that sums up to k, otherwise returns false.

 

Example,

Input - arr = [1, 2, 3, 4], k = 6 

Expected output - true

Explanation - The pair (2, 4) which exists in arr sums to k (It's the only pair also!)

 

Note: arr is not sorted array.

Try it yourself

bool findPair(int* arr, int arrSize, int k) {
    // Write code here
}

All lessons in Interview Coding Challenges - Pack IV

1Challenges

K-Pair (warm-up)K-Pair (follow-up)K,L Domino