prabal nandi wrote:
Can this be done???
prabal nandi wrote:Need code to move element from middle of array to end, without shifting the array elements.
...
3. Elements should not be moved.
Seetharaman Venkatasamy wrote:how is that?
pseudo code :
1. get the copy/value of the elemnet which is at index i ; o(1) since it is an array
2. insert this value at end of the array 0(1)
3. in case you dont want duplicate replace i th position with DUMMY value.
prabal nandi wrote:@jeff: This question was asked to me in an Interview (not by any instructor in any class- so not looking for exact code to copy paste).The interviewer was imposing the restrictions for every approach i was coming up with
Joanne
Joanne Neal wrote:... or the interviewer was probably seeing how you reacted under the pressure of constant changes to a specification - something that you will come up against often in the real world.
prabal nandi wrote:@jeff: This question was asked to me in an Interview (not by any instructor in any class- so not looking for exact code to copy paste).The interviewer was imposing the restrictions for every approach i was coming up with..
So was wondering whether this can be done or not.
The below approach wont server the purpose, as it was asked to remove the cell completely.....
Martin Vajsar wrote:This doesn't seem to be the best way to do that.
Joanne
That sounds fun. You could convert a Java™ array into a C++ array and get a nonsense value at the end. Or even break the object next on the heap after that array.Jeff Verdegan wrote: . . . maybe you could alter the length variable with reflection. Not sure, never tried it. . . .
prabal nandi wrote:please don't tell me that i can face these type of questions in real life scenario.. i have been working as a enterprise app developer for past 3 years.. never faced anything thing remotely closed to the question.
Don't get me started about those stupid light bulbs. |