-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex of sorted arrays.py
51 lines (40 loc) · 1.14 KB
/
Index of sorted arrays.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
44
45
46
47
48
49
50
51
def reduced_array():
a = int(input())
for i in range(1, a):
array_size = int(input())
# takes the array and split to comma separated items
array = list(map(int, input().split(' ')))[:array_size]
# sort the array
sortedArray = sorted(array)
# an empty dictionary that stores the key and values of the sorted array
ranks = {}
result = []
# creates the item and value key
for rank, item in enumerate(sortedArray):
ranks[rank] = item
# reference the first array and find their indexes
for rank, item in ranks.items():
result.insert(array.index(item), rank)
return result
# Output the variable to STDOUT
numbers = [45, 56, 34, 48][0:3]
# start:stop (exclusive)
# print(numbers[0:3])
# print(numbers[:3])
# print("\n")
# print(numbers[1:4])
# print(numbers[1:])
#
# print(numbers)
array = list(map(int, input().split(' ')))
# n = input().split(' ')
# n_map = map(int, n)
# print(n_map)
# print(type(n_map))
# first = n[0]
# print(first)
# print(type(first))
# Type casting
first = array[0]
print(array)
print(type(first))