You can find the average of two sorted arrays by first merging the sorted arrays into a single sorted array, and then finding the median of the merged array. Here's how to do it in TypeScript:
index.ts727 chars29 lines
In this implementation, we use two pointers to iterate over the two arrays and insert the smaller of the two at each step. After the arrays are merged, we find the median of the merged array by checking if its length is even or odd.
Note that the input arrays must be sorted in ascending order for this implementation to work correctly.
gistlibby LogSnag