learning python3 c2

[TOC]

This serious of problems are based on a sorted list (or linked list). Generally we need to make implementation of insert delete elements and combine.

insert is quite easy, in list it takes O(n), and in linked list it takes O(1), for example we insert an element in list[P]

1
2
3
4
5
i = len(list)-1
WHILE i > P
	list[i+1]=list[i] //move the array
	i--
list[i]=list[P]

1