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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

python - GitPython: check if git is available -

How to merge four videos on one screen with ffmpeg -