Skip to content

Instantly share code, notes, and snippets.

@hillal20
Created October 2, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hillal20/bd1c101b006fbee8ad9ca0ed3b96c01f to your computer and use it in GitHub Desktop.
Save hillal20/bd1c101b006fbee8ad9ca0ed3b96c01f to your computer and use it in GitHub Desktop.
PeriodicLazyCoordinates created by hillal20 - https://repl.it/@hillal20/PeriodicLazyCoordinates
let a = [ 1,3,4,7,9]
let b = [ 2,5,6,10,14,18]
function Merge(a,b,n,m){
let c = []
let i = 0;
let j = 0;
let k = 0;
while( i < n && j < m){
if(a[i] < b[j]){
c[k++]= a[i++]
}
else{
c[k++] = b[j++]
}
}
for( ; i < n ; i ++){
c[k++] = a[i]
}
for( ; j < m ; j ++){
c[k++] = b[j]
}
return c
}
console.log(Merge(a,b,a.length , b.length))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment