-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharr.py
44 lines (36 loc) · 794 Bytes
/
arr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import bisect
class Arr:
"""
Creates an array.
"""
def __init__(self):
self.array = []
"""
True iff the item is in the array.
"""
def contains(self, key):
for x in self.array:
if x == key:
return True
return False
"""
Adds the item to the array.
"""
def add(self, key):
self.array.append(key)
"""
Removes the item from the array.
"""
def remove(self, key):
self.array.remove(key)
"""
Returns the item at index index
"""
def get(self, index):
self.array.sort()
return self.array[index]
def sort(self):
l = []
for i in range(len(self.array)):
bisect.insort(l, self.array[i])
return l