Frage im Vorstellungsgespräch bei JPMorganChase

Both questions on simple array manipulation with straightforward optimizing