Created
October 2, 2018 17:36
-
-
Save hillal20/bd1c101b006fbee8ad9ca0ed3b96c01f to your computer and use it in GitHub Desktop.
PeriodicLazyCoordinates created by hillal20 - https://repl.it/@hillal20/PeriodicLazyCoordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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