Bloomberg L.P. Interview Question: unsorted integer array size n... | Glassdoor

Bloomberg L.P.

## Interview Question

2013 Financial Software Developer Interview New York, NY

# unsorted integer array size n. unmodifiable list of "less

than" / "greater than" operators. place elements from int array in between each "&lt;" and "&gt;" operator so that every comparison holds true. e.g. 6, 2, 8, 1, 3, 9, 4, 0, 5, 7 &lt;, &gt;, &lt;, &lt;, &lt;, &gt;, &lt;, &gt;, &gt; answer: 0 &lt; 9 &gt; 1 &lt; 2 &lt; 3 &lt; 8 &gt; 4 &lt; 7 &gt; 6 &gt; 5

0

#include

using namespace std;

bool compare(int data[], const char* optrs, const int& sz) {
int temp;
for (int i = 0 ; i data[i+1]) {
temp = data[i];
data[i] = data[i+1];
data[i+1] = temp;
return false;
}
break;
case '>':
if (data[i] >";
int data[MAX_DATA_SIZE] = {6,2,8,1,3,9,4,0,5,7};

while(!compare(data, optrs, MAX_DATA_SIZE)) {
//Assuming the array data has a solution,
//Include code here to check for when there is no solution!
}

for (int i = 0 ; i < MAX_DATA_SIZE - 1 ; i++)
cout << data[i] << optrs[i];
cout << data[MAX_DATA_SIZE -1] << endl;

return 0;
}

Juan Andrango on Sep 27, 2013
0

Is this the same as a bubble sort, except you need to check each sign, instead of a universal one?

Anonymous on Oct 28, 2013