How to get middle element of array if we don't know size of array -
i asked question in interview ,write algorithm find middle element of array when don't know size of array.
is cheating count elements yourself?
java:
object [] mysteriousarray = getmysteriousarray(); int count = 0; (object value: mysteriousarray) { count++; } object middle = mysteriousarray[count/2];
Comments
Post a Comment