Frage im Vorstellungsgespräch bei Google

Code a self-growing array in java

Antwort im Vorstellungsgespräch

Anonym

21. Dez. 2013

1. Create an array of specific length(say 10) and keep a track of the number of elements the array has. 2. When adding element, increment count and add element to array if space is available. If space is not available create an array of double the original length copy all elements in original element and then add the new element. 3. While deleting decrement count and if array is less than half full, create a new element of half the size and copy elements in the original array