Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript / javascript merge sorted arrays

function MergeSorted(arr1: number[], arr2: number[])
: number[]{
    let x: number = 0;
    let y: number = 0;

    let Arr1Index: number = arr1[x];
    let Arr2Index: number = arr2[y];

    let MergedArray: number[] = [];

    while(Arr1Index || Arr2Index){
        if(!Arr2Index || (Arr1Index < Arr2Index)){
            MergedArray.push(Arr1Index);
            Arr1Index = arr1[x];
            x++;
        }else{
            MergedArray.push(Arr2Index);
            Arr2Index = arr2[y];
            y++;
        }
    }

    return MergedArray;
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: how to make a tool detect a click and add points roblox studio 
Typescript :: vscode Some Rust components not installed. Install? 
Typescript :: You will use an appropriate looping statement to write a script that displays a list of the Celsius equivalents of zero degrees Fahrenheit through 100 degrees Fahrenheit 
Typescript :: how to get file extension from command line arguments in python 
Typescript :: convert int number in f# 
Typescript :: multi select + search + Multiselect and Search in angular 13 
Typescript :: vector with N equal entries R 
Typescript :: does key repeats in hashmap 
Typescript :: Q5: Identify the five major components of a communications system. 
Typescript :: typescript isvalidguid 
Typescript :: keep footer after all elements react 
Typescript :: RuleTester.only(...) 
Typescript :: how to deduct user points when he buy something laravel 
Typescript :: cluster on lists of values that start with a certain value 
Typescript :: box collision detection 
Typescript :: function call in Angular using typescript creates infinite loop 
Typescript :: move between points in godot 
Typescript :: declare function iwth interface typescript 
Typescript :: convert function to arrow function typescript 
Typescript :: FIND TOP 3 students from math_11a table 
Typescript :: are remote objects and distributed objects the same 
Typescript :: components of selenium 
Typescript :: token authentication requirements for git operations 
Typescript :: How to separate two similar names from two lists in Python 
Cpp :: 0009:err:mscoree:CLRRuntimeInfo_GetRuntimeHost Wine Mono is not installed 
Cpp :: how to include everything in c++ 
Cpp :: c++ typedef array 
Cpp :: how to print a decimal number upto 6 places of decimal in c++ 
Cpp :: C++ red text output 
Cpp :: c++ convert binary string to decimal 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =