Hi ! This has been causing me a lot of hardship to find a reasonably elegant solution. I have an array of ints that I want to sort. Conditions are:
0-Do not touch element [0]
1-Remove all other empty entries between values in the array by shifting down the values and placing the '0' at the end
2-Keep track of a nonzero userValue position and rotate it with the array of ints
3-Rotate such that 'current position' is always the 3rd last nonzero element in the array of ints
**For example we have:**
1 2 3
int theValues[9] = {0, 40, 20, 0, 100, 60, 0, 66, 15};
int userValue = 4;
int position = 2; //the current position