Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Basics

Home > Programs > Basics

3 / 248

Given a sorted array and an item k, write a program to get a pair of items whose subtraction equal to K.

Answer:

#include 

#include
using namespace std;
/* The function assumes that the array is sorted */
bool findPair(int arr[], int size, int n)
{
    /* Initialize positions of two elements */
    int i = 0;  
    int j = 1;
    /* Search for a pair */
    while (i

Asked In :: Adobe

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: