Jshacker

Jshacker

Share

14/01/2019

Sorted array find a pair of sum

function arrayPairSum(arr, k){
let left =0; let right = arr.length -1;
let result = [];
while(left < right){
let sum = arr[left] + arr[right];
console.log(sum);
if(k == sum){
result = [arr[left], arr[right]];
left+=1;
}else if(k > sum){
left+=1;
}else{
right-=1;
}
}
return result;
}

arrayPairSum([1,2,3,5,6,7,8,11,15],13); // [6,7]

Philip Roberts: What the heck is the event loop anyway? | JSConf EU 2014 13/03/2016

Philip Roberts: What the heck is the event loop anyway? | JSConf EU 2014 JavaScript programmers like to use words like, “event-loop”, “non-blocking”, “callback”, “asynchronous”, “single-threaded” and “concurrency”. We say things l...

Want your business to be the top-listed Computer & Electronics Service in Hyderabad?
Click here to claim your Sponsored Listing.

Website

Address

Hyderabad