+ 7
Array sorting Challenge
sort an array of elements containing positive and negative numbers The Negative numbers should take the odd positions starting with negative number and then followed by positive numbers. If the array contains more number of positive or negative irrespectively then the left over numbers should take remaining positions. case 1:- array are{2,6,-8,9,0,-2,-5} output:- -8 0 -5 2 -2 6 9 Conditions:- 1) try with one array. 2) Treat 0 as positive number. 3) Use any language. 4)Return null if array is empty.
8 odpowiedzi
+ 9
Here's my C# implementation ✌
No LINQ One-Liner but TWO this time as I couldn't make it without complicating things. Anyway it fully utilize the LINQ feature and work with any number of positive and negative numbers. Enjoy!
https://code.sololearn.com/cBohh2LE7g88/?ref=app
+ 6
that's mine.. 🐍
https://code.sololearn.com/cn0421W5Jrj5/?ref=app
+ 6
@luka & @sayan There's a bug in your program which failed to pass [-1, 2, 3].
+ 2
can you try the same using only single array in JAVA
+ 2
conditions have been modified please go through
+ 1
here you goo
https://code.sololearn.com/cVtxH8p9QBpv/?ref=app
0
@@@
luka
@@@
Ekansh
HAVE U READ THE CHALLENGE...????
ITS TOTALLY DIFFERENT THAN SIMPLE ARRAY SORT THAT YOU DID.
- 1
u need another 2 array...
for keeping positive and negetive nums of initial array...