We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
wtf happen to my editor? my Typescript just only main() and have no input, nothing.
functionmain(){// Enter your code here}
update my answer
/** * Typescript was corrupted and have no any codes, i was switch to Javascript * and copy it function to this test */functionloopInvariant(ar:number[]):void{for(leti=1;i<ar.length;i++){varvalue=ar[i];varj=i-1;//while (j > 0 && ar[j] > value) { // Wrong here. changes "j > 0" to "j >= 0"while(j>=0&&ar[j]>value){ar[j+1]=ar[j];j=j-1;}ar[j+1]=value;}console.log(ar.join(' '));}functionmain(){constn:number=parseInt(readLine().trim(),10);constarr:number[]=readLine().replace(/\s+$/g,'').split(' ').map(arrTemp=>parseInt(arrTemp,10));loopInvariant(arr);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Correctness and the Loop Invariant
You are viewing a single comment's thread. Return to all comments →
wtf happen to my editor? my Typescript just only
main()
and have no input, nothing.update my answer