int i=lenA-1;
int j=lenB-1;

while (j>=0)
{
  if (A[i] >B[j]) {swap(A[i] ,B[j]); sort(A); }
  j--;
}



Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Sat, May 28, 2011 at 11:09 PM, ross <jagadish1...@gmail.com> wrote:

> Hi all,
> Given 2 sorted arrays: A and B each holding n and m elements
> respectively,.
> Hence, total no. of elements = m+n
> Give an algorithm to place the smallest 'm' elements(out of the m+n
> total available) in A and the largest 'n' elements in B. ( A and B
> need not be sorted in the end)
>
> eg:
> A : 1 2 3 B: 0 1.5 4 5 9
>
> Output:
> A can contain any combination of nos 0,1,1.5
> and B should contain 2 3 4 5 9 (in any order.)
>
> Constraints: No extra space. Linear Time preferred
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to