navishsahu
BAN USER
Questions (1)
Comments (3)
Reputation 0
- 0of 0 votes
AnswersI have an two arrays int[] 1 = {2,5,8,9}; and int[] 2={6,3,4,7,1};
- navishsahu in India for 5
I need to merge this two array in third array int[] 3 = new int[1.Length + 2.Length]; and give the output in sorted form.
Also I need to provide and optimized code with minimal complexity...
Output: {1,2,3,4,5,6,7,8,9}
Plz Help...| Report Duplicate | Flag | PURGE
xyz Applications Developer Arrays
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
That is the main challenge here...
I do not have to use any in built methods as well as i need to maintain complexity...
Comment hidden because of low score. Click to expand.
0
of 0 vote
int i = 0, j = 0;
while (i + j < array3.Length)
if (j == array2.Length || ((i < array1.Length) && (array1[i] < array2[j])))
array3[i + j] = array1[i++];
else
array3[i + j] = array2[j++];
Is this the correct way to merge 2 arrays...
- navishsahu April 03, 2015Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
That is the main challenge here...
- navishsahu April 05, 2015I do not have to use any in built methods as well as i need to maintain complexity...