wu :: forums
« wu :: forums - rearrange array »

Welcome, Guest. Please Login or Register.
May 1st, 2024, 11:49pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: SMQ, ThudnBlunder, william wu, Eigenray, Icarus, towr, Grimbal)
   rearrange array
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: rearrange array  (Read 846 times)
m_aakash
Junior Member
**





   


Posts: 96
rearrange array  
« on: Mar 19th, 2008, 7:09am »
Quote Quote Modify Modify

Given two arrrays, one with actual elements, other with 0,-1 or 1 values. 0 says that the corresponding element in the other array is at correct position. 1 indicates the corresponding element in the other array should move forward. -1 indicates move backward. if it is possible to satisfy these constraints, return the new array or return -1.
 
input =    { 1, 2, 4, 5, 7, 8 }  
critique ={ 0, 1, 0, -1, 1, -1 }
output = { 1, 5, 4, 2, 8, 7 }
 
input =    { 1, 2, 4, 5, 7, 8 }  
critique ={ 0, 1, 0, -1, -1, 0 }
output = { 1, 5, 4, 7, 2, 8 }
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: rearrange array  
« Reply #1 on: Mar 19th, 2008, 7:56am »
Quote Quote Modify Modify

Seems to be the same as this topic.
« Last Edit: Mar 19th, 2008, 7:57am by towr » IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
m_aakash
Junior Member
**





   


Posts: 96
Re: rearrange array  
« Reply #2 on: Mar 19th, 2008, 10:05am »
Quote Quote Modify Modify

on Mar 19th, 2008, 7:56am, towr wrote:
Seems to be the same as this topic.

 
thanks towr for providing the link.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board