Author |
Topic: rearrange array (Read 869 times) |
|
m_aakash
Junior Member
 

Posts: 96
|
 |
rearrange array
« on: Mar 19th, 2008, 7:09am » |
Quote 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 |
|
|
|
m_aakash
Junior Member
 

Posts: 96
|
 |
Re: rearrange array
« Reply #2 on: Mar 19th, 2008, 10:05am » |
Quote Modify
|
on Mar 19th, 2008, 7:56am, towr wrote: thanks towr for providing the link.
|
|
IP Logged |
|
|
|
|