Implement a Dynamic Array Vector
Problem statement
Implement a vector with a manually managed backing array. Process parallel operations and arguments:
append [value]: add a value.get [index]: return the value.set [index,value]: replace a value.pop []: remove and return the last value.size []: return the current size.
Return one string per command, using "null" for append and set. Grow the backing capacity geometrically; do not use a built-in resizable collection for stored elements.
Function
runDynamicVector(operations: String[], arguments: int[][]) → String[]Examples
Example 1
operations = ["append","append","get","set","pop","size"]arguments = [[4],[7],[0],[0,9],[],[]]return = ["null","null","4","null","7","1"]The set changes the remaining first value to 9 after pop removes 7.
Constraints
- At most
10^5commands. - Indices and pop operations are valid.