Софтуерно Инженерство
+ Нов въпрос
Xadera avatar Xadera 5 Точки

03. Array Manipulator - List Excercises

03.* Array Manipulator

Write a program that reads an array of integers from the console and set of commands and executes them over the array. The commands are as follows:

  • add <index> <element> – adds element at the specified index (elements right from this position inclusively are shifted to the right).
  • addMany <index> <element 1> <element 2> … <element n> – adds a set of elements at the specified index.
  • contains <element> – prints the index of the first occurrence of the specified element (if exists) in the array or -1 if the element is not found.
  • remove <index> – removes the element at the specified index.
  • shift <positions>shifts every element of the array the number of positions to the left (with rotation).
    • For example, [1, 2, 3, 4, 5] -> shift 2 -> [3, 4, 5, 1, 2]
  • sumPairs – sums the elements in the array by pairs (first + second, third + fourth, …).
    • For example, [1, 2, 4, 5, 6, 7, 8] -> [3, 9, 13, 8].
  • print – stop receiving more commands and print the last state of the array.


Така, имам следният проблем: 

Кодът ми (ЦЪК!) гърми на последната проверка за memory (трябват му 0.3MB, за да мине). Какво мога да направя за да го оптимизирам?

Fundamentals Module
Curious avatar Curious 33 Точки

Използвай само 1 лист, махни го тоя "result", така би трябвало да стане

EDIT: видях защо го ползваш, трябва да я погледна по-обстойно.

01/02/2017 23:42:59
Curious avatar Curious 33 Точки

Виж къде можеш да използваш масиви, вместо листове.

qynajatove avatar qynajatove 1 Точки

Array manipulators use some commands and operations to understand some labels and attributes of an array. To sum up this discussion oxbridge essays you should know about the benefits of the array manipulators.