Професионална програма
Loading...
+ Нов въпрос
llechev avatar llechev 0 Точки

4. List Operations

You will be given a list of integer numbers on the first line of input. You will be receiving operations you have to apply on the list until you receive the "End" command. The possible commands are:

  • Add {number} add number at the end.
  • Insert {number} {index} insert number at given index.
  • Remove {index} remove at index.
  • Shift left {count} first number becomes last ‘count’ times.
  • Shift right {count} last number becomes first ‘count’ times.

Note: there is a possibility that the given index is outside of the bounds of the array. In that case print "Invalid index"

Examples

Input

Output

1 23 29 18 43 21 20

Add 5

Remove 5

Shift left 3

Shift left 1

End

43 20 5 1 23 29 18

5 12 42 95 32 1

Insert 3 0

Remove 10

Insert 8 6

Shift right 1

Shift left 2

End

Invalid index

5 12 42 95 32 8 1 3

Кода: https://pastebin.com/z3saWP7N

Дава ми 83/100 с time limit на последните 2 теста. Някакви идеи защо?

0
Fundamentals Module
PetarNeshkov5360 avatar PetarNeshkov5360 23 Точки

Здравей! Ето ти едно примерно решение!

https://pastebin.com/MQj3080M

0