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

php - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -